【发布时间】:2016-02-06 09:12:07
【问题描述】:
我已经根据文档配置了 yii2-swiftmailer,但是当我发送邮件时显示此错误:
别名“yii.swiftmailer”无效。确保它指向一个现有的目录或文件。
C:\xampp\htdocs\hotel\protected\controllers\HomeController.php(250)
246
247 public function actionMail()
248 {
249
250 Yii::app()->mailer->compose()
251 ->setTo('example@gmail.com')
252 ->setFrom('example2@gmail.com')
253 ->setSubject('Invite')
254 ->setTextBody('Hello!')
255 ->send();
256
257 }
258 }
还有我的扩展文件夹... 扩展\yii2-swiftmailer
和我的配置:
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,//set this property to false to send mails to real email addresses
//comment the following array to send mail using php's mail function
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => '',
'password' => '',
'port' => '587',
'encryption' => 'tls',
],
],
【问题讨论】:
标签: php yii yii2 swiftmailer yii-extensions