Phpmailer Send Message Class library

Source: Internet
Author: User
Phpmailer Send Message Class library
  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 = "Administrator";
  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); Note to give absolute path
  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 "Message error message:". $mail->errorinfo;
  27. }else{
  28. echo "Mail sent successfully!";
  29. }
  30. }
  31. $body = '
  32. Welcome to Http://www.sdfsadfsfsdf.com.

  33. Thank you for registering as a member of this site!

  34. ';
  35. Parameter description (send address, message subject, message content, attachment absolute path)
  36. Smtp_mail (' 2342342342342@qq.com ', ' Welcome to your arrival ', $body, Array (' c:/xampp/htdocs/. txt '));
  37. ?>
Copy Code
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.