Php mail sending method-test availability, email. class. php expiration solution

Source: Internet
Author: User
Php mail sending method-test available, email. class. php expiration solution although php provides the mail () function, it is not easy to use, and PHPMailer is a good mail sending tool, it is also very easy to use!
Use PHPMailer to send an email:

 IsSMTP (); $ mail-> CharSet = 'utf-8'; // It is important to set the character encoding of the email. Otherwise, Chinese characters are garbled. $ mail-> SMTPAuth = true; // enable authentication $ mail-> Port = 25; $ mail-> Host = "smtp.163.com"; $ mail-> Username = "phpddt1990@163.com "; $ mail-> Password = "this is the Password"; // $ mail-> IsSendmail (); // comment out the code if no sendmail component is available; otherwise, "cocould not execute: /var/qmail/bin/sendmail error message $ mail-> AddReplyTo ("phpddt1990@163.com", "mckee "); // reply address $ mail-> From = "phpddt1990@163.com"; $ mail-> F RomName = "www.guodongkeji.com"; $ to = "987044391@qq.com"; $ mail-> AddAddress ($ to); $ mail-> Subject = "phpmailer test title "; $ mail-> Body = "phpmail demo this is the test content for phpmailer in php (www.guodongkeji.com)"; $ mail-> AltBody = "To view the message, please use an HTML compatible email viewer! "; // When the email does not support html, it can be displayed in backup mode. you can omit $ mail-> WordWrap = 80; // set the length of each line's string // $ mail-> AddAttachment ("f:/test.png"); // you can add attachments $ mail-> IsHTML (true ); $ mail-> Send (); echo 'email sent ';} catch (phpmailerException $ e) {echo "email failed to be sent :". $ e-> errorMessage () ;}?>

Open my QQ email and you will see:

The test was successful:
As you can see, PHPMailer supports html format sending, and supports sending images and attachments! It has been tested to be compatible with various SMTP servers!
If an error occurs when adding an attachment:
That is because (set_magic_quotes_runtime () has been disabled. This feature has been completely removed from PHP6.
You can comment out or delete the wrong row, or add the @ symbol before set_magic_quotes_runtime ().
Or configure error_reporting = E_ALL &~ E_NOTICE &~ E_DEPRECATED
PHPMailer and test file download: http://pan.baidu.com/s/1dDJizpJ

For more information, see APP development.

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.