UNIX艺术

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

使用YiiMailMessage发送邮件:

安装yii-mail到protected/extension下

配置protected/config/main.php,如下
'import' => array(
......
'application.extensions.yii-mail.*',
),

......
'components' => array(
'mail' => array(
'class' => 'application.extensions.yii-mail.YiiMail',
'transportType' => 'smtp', /// case sensitive!
'transportOptions' => array(
'host' => 'mail.syncomni.com',
'username' => 'huajian@syncomni.com',
// or email@googleappsdomain.com
'password' => 'Sitbwp4m2w',
// 'port' => '465',
// 'encryption' => 'ssl',
),
// 'viewPath' => 'application.views.mail',
'logging' => true,
'dryRun' => false
),
),
发送邮件
// 发送电子邮件
$message = new YiiMailMessage;
$message->setSubject($model->notice_subject);
$message->setBody($model->notice);
$message->setTo('kevin@syncomni.com');
$message->from = Yii::app()->params['adminEmail'];
Yii::app()->mail->send($message);

posted on 2013-02-17 10:55  jinhuawang76  阅读(250)  评论(0编辑  收藏  举报