Send mail using Phpmailer

Source: Internet
Author: User
Tags vars

Phpmailer's official website: http://phpmailer.worxware.com/

Phpmailer Latest Class Library: "Click to download"

Phpmailer Github:https://github.com/synchro/phpmailer, this page also provides examples of use, but not very comprehensive.

To use the method, see the code listing:

[PHP]View PlainCopy
  1. <?php
  2. Header (' content-type:text/html;  Charset=utf-8 ');
  3. Require './phpmailerautoload.php ';
  4. $mail = new Phpmailer;
  5. $mail->issmtp (); //Set up mail using SMTP
  6. $mail->host = ' mail.wanzhao.com '; //mail server address
  7. $mail->smtpauth = true; //Enable SMTP authentication
  8. $mail->charset = "UTF-8"; //Set message encoding
  9. $mail->setlanguage (' zh_cn '); //Set error Chinese tips
  10. $mail->username = ' [email protected] '; //SMTP user name, which is the personal email address
  11. $mail->password = ' www123456 '; //SMTP password, which is the personal mailbox password
  12. $mail->smtpsecure = ' TLS '; //settings enable encryption, note: The Php_openssl module must be turned on
  13. $mail->priority = 3; //Set Message Priority 1: High, 3: normal (Default), 5: Low
  14. $mail->from = ' [email protected] '; //Sender email address
  15. $mail->fromname = ' ru li star '; //Sender name
  16. $mail->addaddress (' [email protected] ', ' Lee '); //Add recipient
  17. $mail->addaddress (' [email protected] '); //Add multiple recipients
  18. $mail->addreplyto (' [email protected] ', ' information '); //Add a reply to a person
  19. $mail->ADDCC (' [email protected] '); //Add cc person
  20. $mail->ADDCC (' [email protected] '); //Add multiple cc people
  21. $mail->confirmreadingto = ' [email protected] '; //Add send receipt e-mail address, that is, when the recipient opens the message, asks if receipts have occurred
  22. $mail->addbcc (' [email protected] '); //Add dongle, Mail header will not display the secret send the person information
  23. $mail->wordwrap = 50; //Set line wrap 50 characters
  24. $mail->addattachment ('./1.jpg '); //Add attachments
  25. $mail->addattachment ('/tmp/image.jpg ', ' one pic '); //Add multiple attachments
  26. $mail->ishtml (TRUE); //Set message format to HTML
  27. $mail->subject = ' Here is the theme ';
  28. $mail->body = ' This is the HTML information Body <b>in bold!</b>. Time: '.  date (' y-m-d h:i:s ');
  29. $mail->altbody = ' This is the principal in plain text for non-html mail clients ';
  30. if (! $mail->send ()) {
  31. echo ' Message could not being sent. ';
  32. echo ' Mailer Error: '.  $mail->errorinfo;
  33. exit;
  34. }
  35. Echo ' Message has been sent ';

Send mail using Phpmailer

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.