Home > php教程 > php手册 > body text

PHPMailer 命名空间版

WBOY
Release: 2016-06-07 11:40:57
Original
1533 people have browsed it

对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元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template