Phpmailer sending mail

Source: Internet
Author: User

After a long time, finally in the Gmail test success, if there is a successful QQ or 163 mailbox test, convenient words, trouble to tell detailed configuration.

Phpmailer:

Phpmailer:https://github.com/phpmailer/phpmailer

First, the basic requirements

    • Web Access is normal (Apache can access it normally)
    • PHP is set up correctly (Sockets support, OpenSSL two are set to enable)
    • Gmail settings, allowing less secure apps: Enabled

Can write a simple sentence to test: info.php

<? PHP Phpinfo ();? >

Unzip the downloaded Phpmailer to the web directory, my directory structure is as follows: (the main file is circled in the red box, in the directory than you extracted after the file, please do not mind)

Second, gmailer.php set

The need to mark as ***xxx*** is changed to its own information.

<?PHPrequire' Phpmailerautoload.php '; With Gmailer in the Phpmailer folder$mail=NewPhpmailer;$mail->smtpdebug = 1;//Enable verbose debug output$mail-&GT;ISSMTP ();//Set Mailer to use SMTP$mail->host = ' smtp.gmail.com ';//Specify main and backup SMTP servers$mail->smtpauth =true;//Enable SMTP Authentication$mail->username = ' ***[email protected]*** ';//SMTP username$mail->password = ' ***your_gmail_password*** ';//SMTP Password$mail->smtpsecure = ' SSL ';//Enable TLS encryption, ' SSL ' also accepted$mail->port = 465;//TCP port to connect to$mail->setfrom (' ***[email protected]*** ', ' Mailer ');//ADD set from ID$mail->addaddress (' ***starnight_cyber at Foxmail. com*** ', ' Receiver ');//Add a recipient$mail->addaddress (' ***neverthinkaboutit at 163. com*** ', ' Receiver ');//Add a recipient$mail->subject = ' Helo, it is a test! ';$mail->body = ' This is the HTML message Body <b>in bold!</b> ';$mail->altbody = ' The body in plain text for non-html mail clients ';if(!$mail-Send ()) {    Echo' Message could not being sent. '; Echo' Mailer Error: '.$mail-ErrorInfo;} Else {    Echo' Message has been sent ';}?>

Access page: http://localhost/phpmailer/gmailer.php, you will get the following output, showing that the send is correct. (The picture quality is too poor to display)

Here is the recipient's case: (after the message is sent, you need to wait a minute or so to see the message, with Gmail will be faster)

Finally, attach: IMAP/SMTP/POP3 address of gmail,qmail,163 mailbox

Welcome to my message contact ...

Phpmailer sending mail

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.