Php Send mail Method-Pro test available, email.class.php expiration resolution

Source: Internet
Author: User
Tags php send mail

Although PHP provides the mail () function, but it does not work well, and Phpmailer is a good mail sending tool, the use of it is very simple!
To send a message using Phpmailer:

<?PHPHeader("Content-type:text/html;charset=utf-8"); Ini_set("Magic_quotes_runtime", 0); require' Class.phpmailer.php '; Try { $mail=NewPhpmailer (true); $mail-issmtp ();$mail->charset= ' UTF-8 ';//set the character encoding of the message, which is important, otherwise Chinese garbled$mail->smtpauth =true;//Turn on authentication$mail->port = 25; $mail->host = "Smtp.163.com"; $mail->username = "[Email protected]"; $mail->password = "This is the password"; //$mail->issendmail ();//If no SendMail component is commented out, "Could not execute:/var/qmail/bin/sendmail" error message appears$mail->addreplyto ("[Email protected]", "McKee");//Reply to address$mail->from = "[Email protected]"; $mail->fromname = "Www.guodongkeji.com"; $to= "[Email protected]"; $mail->addaddress ($to); $mail->subject = "Phpmailer Test title"; $mail->body = "; $mail->altbody = "To view the message, please use an HTML compatible email viewer!";//alternate display when the message does not support HTML, you can omit$mail-WordWrap= 80;//sets the length of string per line//$mail->addattachment ("f:/test.png");//You can add attachments$mail->ishtml (true); $mail-Send ();Echo' Mail has been sent '; } Catch(phpmailerexception$e) { Echo"Message sent failed:".$e-errormessage ();} ?>

Open my QQ mail to see:

The test went very well:
As can be seen, Phpmailer is supported in HTML format, and supports sending pictures, attachments! Tested, compatible with all kinds of SMTP servers!
Add Attachment if error:
That's because (Set_magic_quotes_runtime ()) has been closed. This feature has been completely removed from the PHP6.
You can comment or delete the line that went wrong, or add the @ sign before set_magic_quotes_runtime ()
or configuration; error_reporting = E_all & ~e_notice & ~e_deprecated
Phpmailer and test file download: Http://pan.baidu.com/s/1dDJizpJ

For more information, please contact: app Development

Php Send mail Method-Pro test available, email.class.php expiration resolution

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.