Phpmailer is an excellent php third-party email sending function, which supports almost all domestic and foreign email login and sending functions. let's take a look at the example of using PHPMailer plug-in php to implement gmail mail sending, I hope this tutorial is intended for large... phpmailer is an excellent php third-party email sending function, which supports almost all domestic and foreign email login and sending functions. let's take a look at the example of using PHPMailer plug-in php to implement gmail mail sending, I hope this tutorial will be helpful to you.
PHPMailer is a mail sending class specifically used in php language. it has powerful functions and enriches PHP's single mail () function. Supports SMTP and attachments. PHPMailer complies with LGPL authorization and can be downloaded for free.
: Http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/PHPMailer%20v5.1/PHPMailer_v5.1.zip/download
Use method (only mail is used, and its function of receiving mail is too popular): The code is as follows:
SMTPAuth = true; // smtp requires authentication $ mail-> SMTPSecure = 'SSL '; // smtp authentication method $ mail-> Port = 465; // smtp port number $ mail-> Username = "username@gmail.com"; // registered gmail user mailbox (you can use your gmail mailbox) $ mail-> Password = "password"; // Password $ mail-> Host = 'smtp .gmail.com '; // mail server $ mail-> IsHTML (true ); // whether HTML mail is supported. the default value is false. $ mail-> From = 'username @ gmail.com '; // The sender's email address, you can use your gmail email address $ mail-> FromName = 'mailer'; // Your Name $ mail-> Subject = 'Mail title'; // mail Title $ mail-> Body = 'Hello World'; // mail content, supports HTML code $ mail-> AddAddress ('name @ anydomain.com ', 'First LA'); // recipient's email address and name if (! $ Mail-> Send () {echo $ mail-> ErrorInfo;}?>
Generally, emails can be sent through the specified smtp server according to the above configuration. However, after my personal test, the above settings can only send emails using 163,126 smtp, such as qq, gmail and so on cannot be sent! After searching for N on google for a long time, I finally found the following method to successfully send emails via gmail. of course, it also includes qq, sina, sohu, etc (Yahoo cannot pass, it seems that Yahoo has not activated smtp by default. you have to activate one of their mail reminders to activate smtp/pop3)
The following is a solution: you only need to find the following code in class. phpmailer. php (the downloaded version may be slightly different). The code is as follows:
Port;}?>
Change to (any version is changed to the following content ):
Port;}?>
After several modifications, I hope you can send emails smoothly through smtp in gmail (of course, you must be able to send emails under win, you have to install smtp in IIS and support OpenSSL extensions in php.) Finally, after testing, the modified smtp can successfully send emails through 126163qqgmailsinasohu.
Tutorial URL:
You are welcome to add your _ favorites to the Favorites folder, but please keep the link for this article.