[英]Mail is not working in yii2
I am using below code to send email in yii2: 我正在使用以下代码在yii2中发送电子邮件:
In config/main.php 在config / main.php中
return [
'components' => [
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail'
],
],
];
In my controller: 在我的控制器中:
Yii::$app->mailer->compose('contact', [
'name' => 'Dan Drown',
'address' => '111 Highway 50, CA'])
->setFrom('dandrown@gmail.com')
->setTo('dandrown@gmail.com')
->setSubject('Re: Hello word')
->send();
But I didn't get any mail in mail dandrown@gmail.com. 但是我没有收到任何邮件dandrown@gmail.com。 And I don't know why?
我不知道为什么? What's the issue?
怎么了
Here is an example of properly configured mailer: 这是正确配置的邮件程序的示例:
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'localhost',
'username' => 'username',
'password' => 'password',
'port' => '587',
'encryption' => 'tls',
],
],
You can read more here: http://www.yiiframework.com/doc-2.0/yii-swiftmailer-mailer.html 您可以在此处阅读更多信息: http : //www.yiiframework.com/doc-2.0/yii-swiftmailer-mailer.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.