使用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);