diff --git a/common/config/main.php b/common/config/main.php index dab8b2e..f739c3b 100755 --- a/common/config/main.php +++ b/common/config/main.php @@ -51,5 +51,17 @@ 'useFilename' => true, 'absoluteUrl' => false, ], + 'mailer' => [ + 'class' => 'yii\swiftmailer\Mailer', + 'transport' => [ + 'class' => 'Swift_SmtpTransport', + 'host' => 'smtp.gmail.com', + 'username' => 'clud.net.mails@gmail.com', + 'password' => 'a3E6yNb9KUtF', + 'port' => '587', + 'encryption' => 'tls', + ], + 'viewPath' => '@common/mail', + ], ], ]; diff --git a/common/mail/feedback.php b/common/mail/feedback.php new file mode 100644 index 0000000..96ae435 --- /dev/null +++ b/common/mail/feedback.php @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
Имяname?>
Телефонphone?>
Emailemail?>
Комментарийmessage)?$model->message:''?>
Urlurl?>
diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 8575678..bf2168d 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -106,17 +106,42 @@ } else { $model = new Feedback(); if ($model->load(Yii::$app->request->post()) && $model->save()) { - return [ - 'success' => true, - 'message' => 'Success message', - 'alert' => '
-

Success

-

- Success text -

-
', - ]; - } else { + + $mailer = \Yii::$app->mailer->compose( + 'feedback', + [ + 'model' => $model, + ] + ) + ->setFrom('tamerlan8.05.92@gmail.com') + ->setTo( + [ + 'tamerlan8.05.92@gmail.com', + 'kazimirova.artweb@gmail.com', + + ] + ); + if($mailer->send()){ + return [ + 'success' => true, + 'message' => 'Success message', + 'alert' => '
+

Success

+

+ Success text +

+
', + ]; + } + else{ + return [ + 'success' => false, + 'error' => 'mail didn\'t send', + ]; + } + + } + else { return [ 'success' => false, 'error' => $model->errors, diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 6f27cf6..5c30e2c 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -403,7 +403,7 @@ _________________________________________________________ -->