в конфиге у меня настроено так:
Код: Выделить всё
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.google.com',
'username' => 'моя почта',
'password' => 'мой пароль',
'port' => '465',
'encryption' => 'ssl',
],
],
Код: Выделить всё
public function actionIndex()
{
$requests = new Requests();
if ($requests->load(Yii::$app->request->post())) {
if ($requests->save()) {
Yii::$app->session->setFlash('success', 'Ваша заявка на техническое обслуживание принята');
/*Yii::$app->mailer->compose()
->setTo(Yii::$app->params['adminEmail'])
->setFrom('????')
->setSubject('новая заявка')
->send();
*/
return $this->render('ok');
} else {
Yii::$app->session->setFlash('error', 'Ошибка');
}
}
return $this->render('index', compact('requests'));
}