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.