Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'mailer' => [
- 'class' => 'yiiswiftmailerMailer',
- 'viewPath' => '@common/mail',
- 'useFileTransport' => false,
- 'transport' => [
- 'class' => 'Swift_SmtpTransport',
- 'host' => 'smtp.yandex.ru',
- 'username' => 'test@prioriticlub.ru',
- 'password' => 'password',
- 'port' => '587',
- 'encryption' => 'TLS',
- ],
- ],
- Expected response code 250 but got code "553", with message "553 5.7.1 Sender address rejected: not owned by auth user."
- 'mailer' => [
- 'class' => 'yiiswiftmailerMailer',
- 'viewPath' => '@app/mail',
- 'transport' => [
- 'class' => 'Swift_SmtpTransport',
- 'host' => 'smtp.yandex.ru',
- 'username' => 'test@yandex.ru',
- 'password' => '**********',
- 'port' => 465,
- 'encryption' => 'ssl',
- ],
- 'useFileTransport' => false,
- ],
- public function contact($email)
- {
- $content = "<p>Email: " . $this->email . "</p>";
- $content .= "<p>Name: " . $this->name . "</p>";
- $content .= "<p>Subject: " . $this->subject . "</p>";
- $content .= "<p>Body: " . $this->body . "</p>";
- if ($this->validate()) {
- Yii::$app->mailer->compose("@app/mail/layouts/html", ["content" => $content])
- ->setTo('test@yandex.ru')
- ->setFrom([Yii::$app->params['supportEmail'] => $this->name])
- ->setSubject($this->subject)
- ->setTextBody($this->body)
- ->send();
- return true;
- }
- return false;
- }
- return [
- 'adminEmail' => 'test@yandex.ru',
- 'supportEmail' => 'test@yandex.ru',
- ];
- public function actionContact()
- {
- /* Создаем экземпляр класса */
- $model = new ContactForm();
- /* получаем данные из формы и запускаем функцию отправки contact, если все хорошо, выводим сообщение об удачной отправке сообщения на почту */
- if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
- Yii::$app->session->setFlash('contactFormSubmitted');
- return $this->refresh();
- /* иначе выводим форму обратной связи */
- } else {
- return $this->render('contact', [
- 'model' => $model,
- ]);
- }
- }
Add Comment
Please, Sign In to add comment