Commit a1c655185c8a04e6a762e9445d13811664127f39
1 parent
3679cdb6
-Email sending added
Showing
1 changed file
with
21 additions
and
14 deletions
Show diff stats
frontend/controllers/FeedbackController.php
| ... | ... | @@ -32,20 +32,27 @@ |
| 32 | 32 | * @var Mailer $mailer |
| 33 | 33 | */ |
| 34 | 34 | $mailer = \Yii::$app->get('smtpmailer'); |
| 35 | - $mailer->compose( | |
| 36 | - '@frontend/views/mail/_feedback', | |
| 37 | - [ | |
| 38 | - 'model' => $model, | |
| 39 | - ] | |
| 40 | - ) | |
| 41 | - ->setFrom( | |
| 42 | - [ | |
| 43 | - 'artboxcore@gmail.com' => 'ArtBox', | |
| 44 | - ] | |
| 45 | - ) | |
| 46 | - ->setTo('kennen.md@gmail.com') | |
| 47 | - ->setSubject('Заявка с core.artbox.net.ua') | |
| 48 | - ->send(); | |
| 35 | + try { | |
| 36 | + $mailer->compose( | |
| 37 | + '@frontend/views/mail/_feedback', | |
| 38 | + [ | |
| 39 | + 'model' => $model, | |
| 40 | + ] | |
| 41 | + ) | |
| 42 | + ->setFrom( | |
| 43 | + [ | |
| 44 | + 'artboxcore@gmail.com' => 'ArtBox', | |
| 45 | + ] | |
| 46 | + ) | |
| 47 | + ->setTo('kennen.md@gmail.com') | |
| 48 | + ->setSubject('Заявка с core.artbox.net.ua') | |
| 49 | + ->send(); | |
| 50 | + } catch (\Exception $e) { | |
| 51 | + return [ | |
| 52 | + 'status' => true, | |
| 53 | + 'message' => $e->getMessage(), | |
| 54 | + ]; | |
| 55 | + } | |
| 49 | 56 | return [ |
| 50 | 57 | 'status' => true, |
| 51 | 58 | 'message' => 'Success', | ... | ... |