Commit b52e56da9d475715c6c22e69580a4b743642be91
1 parent
ae650ac4
mailing
Showing
4 changed files
with
86 additions
and
12 deletions
Show diff stats
common/config/main.php
| ... | ... | @@ -51,5 +51,17 @@ |
| 51 | 51 | 'useFilename' => true, |
| 52 | 52 | 'absoluteUrl' => false, |
| 53 | 53 | ], |
| 54 | + 'mailer' => [ | |
| 55 | + 'class' => 'yii\swiftmailer\Mailer', | |
| 56 | + 'transport' => [ | |
| 57 | + 'class' => 'Swift_SmtpTransport', | |
| 58 | + 'host' => 'smtp.gmail.com', | |
| 59 | + 'username' => 'clud.net.mails@gmail.com', | |
| 60 | + 'password' => 'a3E6yNb9KUtF', | |
| 61 | + 'port' => '587', | |
| 62 | + 'encryption' => 'tls', | |
| 63 | + ], | |
| 64 | + 'viewPath' => '@common/mail', | |
| 65 | + ], | |
| 54 | 66 | ], |
| 55 | 67 | ]; | ... | ... |
| 1 | +<?php | |
| 2 | + use artbox\core\models\Feedback; | |
| 3 | + | |
| 4 | + /** | |
| 5 | + * Created by PhpStorm. | |
| 6 | + * User: timur | |
| 7 | + * Date: 20.11.17 | |
| 8 | + * Time: 16:57 | |
| 9 | + * | |
| 10 | + * @var Feedback $model | |
| 11 | + */ | |
| 12 | + | |
| 13 | + ?> | |
| 14 | + | |
| 15 | +<table> | |
| 16 | + <tr> | |
| 17 | + <td>Имя</td> | |
| 18 | + <td><?=$model->name?></td> | |
| 19 | + </tr> | |
| 20 | + <tr> | |
| 21 | + <td>Телефон</td> | |
| 22 | + <td><?=$model->phone?></td> | |
| 23 | + </tr> | |
| 24 | + <tr> | |
| 25 | + <td>Email</td> | |
| 26 | + <td><?=$model->email?></td> | |
| 27 | + </tr> | |
| 28 | + <tr> | |
| 29 | + <td>Комментарий</td> | |
| 30 | + <td><?=!empty($model->message)?$model->message:''?></td> | |
| 31 | + </tr> | |
| 32 | + <tr> | |
| 33 | + <td>Url</td> | |
| 34 | + <td><a href="<?=$model->url?>" target=_blank></a><?=$model->url?></td> | |
| 35 | + </tr> | |
| 36 | + | |
| 37 | +</table> | ... | ... |
frontend/controllers/SiteController.php
| ... | ... | @@ -106,17 +106,42 @@ |
| 106 | 106 | } else { |
| 107 | 107 | $model = new Feedback(); |
| 108 | 108 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
| 109 | - return [ | |
| 110 | - 'success' => true, | |
| 111 | - 'message' => 'Success message', | |
| 112 | - 'alert' => '<div class="alert alert-success"> | |
| 113 | - <h3>Success</h3> | |
| 114 | - <p> | |
| 115 | - Success text | |
| 116 | - </p> | |
| 117 | - </div>', | |
| 118 | - ]; | |
| 119 | - } else { | |
| 109 | + | |
| 110 | + $mailer = \Yii::$app->mailer->compose( | |
| 111 | + 'feedback', | |
| 112 | + [ | |
| 113 | + 'model' => $model, | |
| 114 | + ] | |
| 115 | + ) | |
| 116 | + ->setFrom('tamerlan8.05.92@gmail.com') | |
| 117 | + ->setTo( | |
| 118 | + [ | |
| 119 | + 'tamerlan8.05.92@gmail.com', | |
| 120 | + 'kazimirova.artweb@gmail.com', | |
| 121 | + | |
| 122 | + ] | |
| 123 | + ); | |
| 124 | + if($mailer->send()){ | |
| 125 | + return [ | |
| 126 | + 'success' => true, | |
| 127 | + 'message' => 'Success message', | |
| 128 | + 'alert' => '<div class="alert alert-success"> | |
| 129 | + <h3>Success</h3> | |
| 130 | + <p> | |
| 131 | + Success text | |
| 132 | + </p> | |
| 133 | + </div>', | |
| 134 | + ]; | |
| 135 | + } | |
| 136 | + else{ | |
| 137 | + return [ | |
| 138 | + 'success' => false, | |
| 139 | + 'error' => 'mail didn\'t send', | |
| 140 | + ]; | |
| 141 | + } | |
| 142 | + | |
| 143 | + } | |
| 144 | + else { | |
| 120 | 145 | return [ |
| 121 | 146 | 'success' => false, |
| 122 | 147 | 'error' => $model->errors, | ... | ... |
frontend/views/layouts/main.php
| ... | ... | @@ -403,7 +403,7 @@ _________________________________________________________ --> |
| 403 | 403 | </div> |
| 404 | 404 | <div class="modal-body"> |
| 405 | 405 | |
| 406 | - <p>Thank for your reply, we will call you, maybe.</p> | |
| 406 | + <p>Спасибо, ваша заявка принята. Мы свяжемся с вами в ближайшее время</p> | |
| 407 | 407 | <p class="text-center"> |
| 408 | 408 | <button type="button" class="btn btn-template-primary" data-dismiss="modal">Close</button> |
| 409 | 409 | </p> | ... | ... |