Basic Example using SMTP (for Phpmailer v5.0.0 and up)

Source: Internet
Author: User

Sample as below:

Require_once ('.. /class.phpmailer.php ');//include ("class.smtp.php");             Optional, gets called from within class.phpmailer.php if not already loaded$mail = new Phpmailer (); $body = file_get_contents (' contents.html '); $body = Eregi_replace ("[\]" "," ', $body); $mail->issmtp (); Telling the class to use Smtp$mail->host = "mail.yourdomain.com";                     SMTP server$mail->smtpdebug = 2;                                           Enables SMTP debug information (for testing)//1 = errors and messages                  2 = Messages Only$mail->smtpauth = true; Enable SMTP Authentication$mail->host = "mail.yourdomain.com";                    Sets the SMTP server$mail->port = 26; Set the SMTP port for the GMAIL server$mail->username = "[email protected]";        SMTP account Username$mail->password = "YourPassword"; SMTP Account password$mAil->setfrom (' [email protected] ', ' first Last '), $mail->addreplyto ("[email protected]", "First Last  "); $mail->subject =" Phpmailer Test Subject via SMTP, basic with Authentication "; $mail->altbody =" To view the message, please use an HTML compatible email viewer! "; Optional, comment out and test$mail->msghtml ($body); $address = "[email protected]"; $mail->addaddress ($      Address, "John Doe"); $mail->addattachment ("Images/phpmailer.gif"); Attachment$mail->addattachment ("Images/phpmailer_mini.gif"); Attachmentif (! $mail->send ()) {echo "Mailer Error:". $mail->errorinfo;}     else {echo "Message sent!";}

Basic Example using SMTP (for Phpmailer v5.0.0 and up)

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.