I'm using basic Yii2 template and Swiftmailer to send email..
Here is my code for config/web.php
:
'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.gmail.com',
'username' => 'myemail@gmail.com',
'password' => 'password',
'port' => '587',
'encryption' => 'tls',
],
],
and my controller code is:
$fname = Yii::$app->request->post('fname');
$email = Yii::$app->request->post('email');
$industry = Yii::$app->request->post('industry');
$info = Yii::$app->request->post('info');
$mail = Yii::$app->mailer->compose()
->setFrom('myemail@gmail.com')
->setTo($email)
->setSubject('Test mail')
->setTextBody($info)
->send();
I'm getting email logs, but no email is being send...
Thanks.