Reputation: 2557
Following are my Configurations:
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
'transport' => [
'class' => 'Swift_MailTransport',
],
'useFileTransport' => False,
],
I have even tried with followings:
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
'useFileTransport' => False,
],
I'm using following code to send email:
var_dump(\Yii::$app->mailer->compose()
->setTo($email)
->setFrom(\Yii::$app->params['supportEmail'])
->setSubject('Message subject')
->setTextBody('Plain text content')
->setHtmlBody('<b>HTML content</b>')
->send());
But its returning false everytime no exception is thrown.
I have used mail() function to send email for same content, its working fine and email is instant. But issue is only with the SwiftMailer.
I couldn't find way to debug it. I have Yii2Debugger enabled, but I can't fine any info in that as well.
Edit:
I Tried with Gmail SMTP, I'm getting
Connection could not be established with host smtp.gmail.com [Connection timed out #110]
I tried their default SMTP
, I'm not getting any error with that, but still getting false for it.
We are on Sharing hosting env. DO I need to check any PHP Settings.
Upvotes: 2
Views: 6163
Reputation: 1787
try this configuration
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport'=>false,
// 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.
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => '[email protected]',
'password' => 'yourpassword',
'port' => '465',
'encryption' => 'ssl',
],
],
hope it helps :)
Upvotes: -2