【发布时间】:2015-05-14 08:29:59
【问题描述】:
我正在使用基本的 Yii2 模板和 Swiftmailer 来发送电子邮件..
这是我的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',
],
],
我的控制器代码是:
$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();
我收到电子邮件日志,但没有发送电子邮件...
谢谢。
【问题讨论】:
标签: yii2 swiftmailer