【发布时间】:2014-10-17 03:17:52
【问题描述】:
我尝试使用 yii simple mailer 发送邮件...
我按照步骤:
http://www.yiiframework.com/extension/yii-simple-mailer/
并下载扩展并放入 yii 扩展文件夹:
https://github.com/tlikai/YiiMailer
然后把代码放到config/main.php:
'mailer' => array(
// for smtp
'class' => 'ext.mailer.SmtpMailer',
'server' => 'theserver',
'port' => '25',
'username' => 'theadmin',
'password' => 'thepassword',
// for php mail
'class' => 'ext.mailer.PhpMailer',
),
然后在我的控制器中我写了这个代码来发送邮件:
$to = 'wahaha@gmail.com';
$subject = 'Hello Mailer';
$content = 'Some content';
Yii::app()->mailer->send($to, $subject, $content);
然后浏览器给了我错误: 未定义属性“PhpMailer.server”。
我是否遗漏了代码中的某些内容?
【问题讨论】:
-
你的配置文件中添加了扩展类吗?
-
@nosthertus
'class' => 'ext.mailer.SmtpMailer',不考虑添加? -
在你的配置文件中尝试
import=>array('ext.mailer.*'); -
@nosthertus 你的意思是 config/console.php 吗?
-
你的配置
main.php