Php provides the mail () function, but it is not easy to use. PHPMailer is a good email sending tool and is very easy to use! Use PHPMailer to send an email: & amp; lt ;? Php/*** bywww
Php provides the mail () function, but it is not easy to use. PHPMailer is a good email sending tool and is 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-> FromNam E = "www.phpddt.com"; $ to = "phpddt@qq.com"; $ mail-> AddAddress ($ to); $ mail-> Subject = "phpmailer test title "; $ mail-> Body = "phpmail demonstration: this is the test content for phpmailer by php point-through (www.phpddt.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: phpmailer.rar