Phpmailer example of sending Gmail messages

Source: Internet
Author: User
Tags gmail mail gmail password
This article describes the use of Phpmailer to send Gmail mail examples, the need for friends to refer to the next bar.

Use the Phpmailer class to send the Gmail message instance code:

<title>phpmailer-Send Gmail messages _bbs.it-home.org</title>
     ISSMTP (); Telling the class to use Smtp$mail->host = "mail.gmail.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->smtpsecure = "SSL";      Sets the prefix to the Servier$mail->host = "smtp.gmail.com";  Sets GMAIL as the SMTP server$mail->port = 465;  Set the SMTP port for the GMAIL server$mail->username = "* * * @gmail. com"; GMAIL Username$mail->password = "* * *"; GMAIL password$mail->setfrom (' * * * * @gmail. com ', ' first Last '), $mail->addreplyto ("* * * @gmail. com", "First Last "); $mail->subject =" Phpmailer Test Subject via SMTP (Gmail), basic "; $mail->altbody =" To view the message, pl Ease use of an HTML compatible email viewer! "; Optional, comment out and test$mail->msghtml ($body); $address = "* * * @gmail. com"; $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!";}? >

Need to introduce Phpmailer class file, download address: Phpmailer Mail Send class V5.1 download address.

  • 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.