yii mailer 扩展发送邮件

时间:2022-09-24 08:42:38
// 将mailer扩张放到 yii 的extension目录下
$message = 'Hello World!'; $mailer = Yii::createComponent('application.extensions.mailer.EMailer');
$mailer->Host = 'smtp.163.com';
$mailer->IsSMTP();
$mailer->SMTPAuth = true;
$mailer->From = 'e********7@163.com';
$mailer->AddReplyTo('e******7@163.com');
$mailer->AddAddress('4******6@qq.com');
$mailer->FromName = '你大爷';
$mailer->Username = 'es**o**07'; //这里输入发件地址的用户名
$mailer->Password = '8********7'; //这里输入发件地址的密码
$mailer->SMTPDebug = FALSE; //设置SMTPDebug为true,就可以打开Debug功能,根据提示去修改配置
$mailer->CharSet = 'UTF-8';
$mailer->Subject = Yii::t('demo', 'Yii rulez!');
$mailer->Body = $message;
$x = $mailer->Send();