phpmailer sending email library

WBOY
Release: 2016-07-25 09:11:04
Original
1090 people have browsed it
phpmailer 发送邮件类库
  1. header('Content-Type: text/html; charset=utf-8');
  2. require("phpmailer/class.phpmailer.php");
  3. error_reporting(E_ERROR);
  4. function smtp_mail ( $sendto_email, $subject, $body ,$att=array()) {
  5. $mail = new PHPMailer();
  6. $mail->IsSMTP();
  7. $mail->Host = "asdfasdfasdf.com";
  8. $mail->Username = "asdfasdfasdfsd@com.cn";
  9. $mail->Password = "234234234234234";
  10. $mail->FromName = "管理员";
  11. $mail->SMTPAuth = true;
  12. $mail->From = $mail->Username;
  13. $mail->CharSet = "utf-8";
  14. $mail->Encoding = "base64";
  15. $mail->AddAddress($sendto_email);
  16. foreach($att as $key=>$val){
  17. if(!empty($val)){
  18. $mail->AddAttachment($val); //注意要给绝对路径
  19. }
  20. }
  21. $mail->IsHTML(true);
  22. $mail->Subject = $subject;
  23. $mail->Body = $body;
  24. $mail->AltBody ="text/html";
  25. if(!$mail->Send()) {
  26. echo "邮件错误信息: " . $mail->ErrorInfo;
  27. }else{
  28. echo "邮件发送成功!";
  29. }
  30. }
  31. $body = '
  32. 欢迎来到http://www.sdfsadfsfsdf.com

  33. 感谢您注册为本站会员!

  34. ';
  35. // 参数说明(发送地址, 邮件主题, 邮件内容,附件绝对路径)
  36. smtp_mail('2342342342342@qq.com', '欢迎你的到来', $body,array('C:/xampp/htdocs/复件.txt'));
  37. ?>
复制代码


Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!