在Yii Framework中利用PHPMailer发送邮件(2011-06-02 14:06:23)
这个扩展配置十分方便,如果有问题的话,可以打开Debug:
- <?php
- $message = ‘Hello World!‘;
- $mailer = Yii::createComponent(‘application.extensions.mailer.EMailer‘);
- $mailer->Host = <your smtp host>;
- $mailer->IsSMTP();
- $mailer->From = ‘[email protected]‘;
- $mailer->AddReplyTo(‘[email protected]‘);
- $mailer->AddAddress(‘[email protected]‘);
- $mailer->FromName = ‘Wei Yard‘;
- $mailer->SMTPDebug = true;//设置SMTPDebug为true,就可以打开Debug功能,根据提示去修改配置
- $mailer->CharSet = ‘UTF-8‘;
- $mailer->Subject = Yii::t(‘demo‘, ‘Yii rulez!‘);
- $mailer->Body = $message;
- $mailer->Send();
- <?php
- $message = ‘Hello World!‘;
- $mailer = Yii::createComponent(‘application.extensions.mailer.EMailer‘);
- $mailer->Host = ‘smtp.163.com‘;
- $mailer->IsSMTP();
- $mailer->SMTPAuth = true;
- $mailer->From = ‘[email protected]‘;
- $mailer->AddReplyTo(‘[email protected]‘);
- $mailer->AddAddress(‘[email protected]‘);
- $mailer->FromName = myName‘;
- $mailer->Username = ‘username‘; //这里输入发件地址的用户名
- $mailer->Password = ‘password‘; //这里输入发件地址的密码
- $mailer->SMTPDebug = true;//设置SMTPDebug为true,就可以打开Debug功能,根据提示去修改配置
- $mailer->CharSet = ‘UTF-8‘;
- $mailer->Subject = Yii::t(‘demo‘, ‘Yii rulez!‘);
- $mailer->Body = $message;
- $mailer->Send();
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。