PHP mail class library PHPMailer simple use _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHP mail class library PHPMailer is simple to use. Recently, you need to use the mail sending function, which was originally sent using the mail () function provided by PHP. Phpmail () is a simple, convenient, and easy-to-use method. However, apart from NetEase mailbox, QQ mailbox, and the function of sending emails recently, it was originally sent using the mail () function provided by PHP. Php mail () is a simple, convenient, and easy-to-use method. However, in addition to NetEase mailbox, QQ mailbox, GMAIL mailbox, and other frequently used mailboxes, it has been tested that HOTMAIL, TOM, LIVE and other mailboxes cannot receive such emails. Therefore, PHPMailer is the powerful Mail sending class.

Some examples provided by the official website may report Mailer Error: cocould not instantiate mail function. After referring to some materials, I wrote a method myself. The code is very simple and I will not explain it much.

Function mailto ($ nickname, $ address, $ id, $ activation_code) {date_default_timezone_set ('prc'); include_once ("class. phpmailer. php "); $ mail = new PHPMailer (); // defaults to using php" mail () "$ mail-> IsSMTP (); $ mail-> Host = ""; // SMTP server $ mail-> SMTPAuth = true; // open SMTP Authentication $ mail-> Username = " "; // username $ mail-> Password = "yourpassword"; // Password // $ body = file_get_contents ('application/views/nmra/register.html '); // $ body = preg_replace ('// \\\/', '', $ body); // Strip backslashes $ body ='

'; $ Body. ='

'; $ Body. ='

'; $ Body. ='

'. $ Nickname.', hello.

'; $ Body. ='

Congratulations, you have become a member of the Research Association's name'. $ id.

'; $ Body. ='

Bangke Research Association is a community where programmers, siege Lions, design Lions, and developers exchange and discuss technology. I hope you can find topics of interest and like-minded friends here.

'; $ Body. =' Please click the following link to verify your mailbox, please note that the domain name is Code = '. $ activation_code. ''; $ body. ='

I wish you a pleasant job and a pleasant life.

'; $ Body. ='

'; // Echo $ body; $ mail-> AddReplyTo ("", "Gonn"); $ mail-> SetFrom ('bkjia @', 'gonn '); $ mail-> AddReplyTo ("", "Gonn"); $ address = ""; // $ address = ""; $ mail-> AddAddress ($ address, $ nickname); $ subject = "receive an email from the customer's house"; $ mail-> Subject = "=? UTF-8? B? ". Base64_encode ($ subject )."? = "; // Optional, comment out and test $ mail-> AltBody =" To view the message, please use an HTML compatible email viewer! "; $ Mail-> MsgHTML ($ body); // $ mail-> AddAttachment (" images/phpmailer.gif "); // attachment // $ mail-> AddAttachment ("images/phpmailer_mini.gif"); // attachmentif (! $ Mail-> Send () {// echo "Mailer Error:". $ mail-> ErrorInfo;} else {// echo "Message sent! ";}}

When using PHP, you only need to introduce two PHP classes, and then write a method by yourself. The two classes are very small and the Mail sending speed is fast.

PHPMailer is a powerful mail class with its main features:

  1. Supports mail s/mime-encrypted digital signatures
  2. Supports email to multiple TOs, CCs, BCCs and REPLY-TOs
  3. Can work on any server platform, so you don't have to worry about the problem that Windows cannot send emails.
  4. Supports text/HTML emails
  5. Image embedding
  6. The email client does not support HTML reading.
  7. Powerful debugging for sending emails
  8. Custom email header
  9. Support for redundant SMTP servers
  10. Supports 8-bit, base64, binary, and quoted-printable encoding.
  11. Text wrap
  12. Supports sending multiple attachments
  13. Support for SMTP server verification
  14. Tests on Sendmail, qmail, Postfix, Gmail, Imail, and Exchange platforms are successful.
  15. The downloaded files include detailed instructions and examples, so you don't have to worry about getting started!
  16. PHPMailer is very small, simple, convenient, and fast

Sent by the terminate () function. Php mail () is very simple, convenient, and easy to use, but in addition to NetEase mailbox, QQ mailbox ,...

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: 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.