对PHPMailer进行了一点小改造,使之能够使用在ThinkPHP 3.2中使用
将PHPMailer.class.php和Smtp.class.php这两个文件放入ThinkPHP/Library/Vendor文件夹下,然后在控制器中调用:use Vendor\PHPMailer;
函数使用:// 发送邮件<br>
public function sendEmail($content,$email){<br>
$mail = new PHPMailer();<br>
$body = $content;<br>
$mail->IsSMTP();<br>
$mail->SMTPAuth = true; // enable SMTP authentication<br>
$mail->SMTPKeepAlive = true; // sets the prefix to the servier<br>
$mail->CharSet = "utf-8"; // 解决乱码<br>
//send from 163 mail<br>
$mail->Host = "smtp.163.com"; // sets SMTP server<br>
$mail->Port = 25;<br>
$mail->Username = "your email@163.com"; // 用户账号<br>
$mail->Password = "your password"; // 用户密码<br>
$mail->From = "your emai@163.com";<br>
$mail->FromName = "管理员";<br>
$mail->Subject = "密码重置邮件(请勿回复)";<br>
$mail->AltBody = $body;<br>
$mail->WordWrap = 50; // set word wrap<br>
$mail->MsgHTML($body);<br>
$mail->AddReplyTo("your email@163.com","admin");<br>
// $mail->AddAttachment("attachment.jpg"); // 附件1<br>
// $mail->AddAttachment("attachment.zip"); // 附件2<br>
$mail->AddAddress($email,"accept"); //接收邮件的账号<br>
$mail->IsHTML(true); // send as HTML<br>
return $mail->Send();<br>
}
关于通过邮件找回密码的逻辑我就不写了,可移步我的博客http://blue7wings.com/2014/09/18/find-back-you-password-through-email/
PHPMailer.tar.gz ( 22.84 KB 下载:228 次 )
AD:真正免费,域名+虚机+企业邮箱=0元