将phpmailer.class.php和smtp.class.php这两个文件放入thinkphp/library/vendor文件夹下,然后在控制器中调用:use vendor\phpmailer;
函数使用:// 发送邮件
public function sendemail($content,$email){
$mail = new phpmailer();
$body = $content;
$mail->issmtp();
$mail->smtpauth = true; // enable smtp authentication
$mail->smtpkeepalive = true; // sets the prefix to the servier
$mail->charset = utf-8; // 解决乱码
//send from 163 mail
$mail->host = smtp.163.com; // sets smtp server
$mail->port = 25;
$mail->username = your email@163.com; // 用户账号
$mail->password = your password; // 用户密码
$mail->from = your emai@163.com;
$mail->fromname = 管理员;
$mail->subject = 密码重置邮件(请勿回复);
$mail->altbody = $body;
$mail->wordwrap = 50; // set word wrap
$mail->msghtml($body);
$mail->addreplyto(your email@163.com,admin);
// $mail->addattachment(attachment.jpg); // 附件1
// $mail->addattachment(attachment.zip); // 附件2
$mail->addaddress($email,accept); //接收邮件的账号
$mail->ishtml(true); // send as html
return $mail->send();
}关于通过邮件找回密码的逻辑我就不写了,可移步我的博客http://blue7wings.com/2014/09/18/find-back-you-password-through-email/
phpmailer.tar.gz ( 22.84 kb 下载:228 次 )
ad:真正免费,域名+虚机+企业邮箱=0元
