PHPmailer group-sending Gmail FAQ

Source: Internet
Author: User

1. cocould not authenticate first, if you do not use a loop, it is basically an incorrect account or password. If you use a loop to send a group, remember to call Smtpclose () after the send () method ends (), send the email once. Otherwise, only one email is sent, and the second email crashes. 2. gmail first, enable php's ssl permission php to enable openssl. In most cases, openssl is not enabled. To enable openssl, You need to perform the following simple settings: Enable php in windows: 1: first check php. in ini; Whether extension = php_openssl.dll exists. If yes, remove the comment ';'. If no line exists, add extension = php_openssl.dll. 2. Copy the php_openssl.dll, ssleay32.dll, and libeay32.dll files in the php folder to the WINDOWS \ system32 \ folder. 3: restart apache or iis. openssl is enabled now. How to enable openssl in Linux: I am using the cloud host of jinshang data. For PHP version: 5.2.14, the following solution uses my host as an example to explain how to add openssl module support for PHP. Some answers on the Internet are to re-compile PHP, add the configure parameter, and add openssl support. Here is a method that does not need to be re-compiled. If there is a PHP installation package file on the server is best, if you have already deleted, go to download and phpinfo page shows the version of the same PHP installation file, I here is the php-5.2.14.tar.gz recommended to download Sohu image, netease image not found. Address: The http://mirrors.sohu.com/php/ connects to the host with an ssh tool. # Download to/var/www/php5 directory cd/var/www/php5 wget http://mirrors.sohu.com/php/php-5.2.14.tar.gz # unzip tar zxvf php-5.2.14.tar.gz # Enter PHP openssl extension Module Directory cd php-5.2.14/ext/openssl/ /var/www/php5/bin/phpize # Here is your phpize path, if not found, use whereis phpize to find # after execution, the config cannot be found if an error is found. m4, config0.m4 is config. m4. Rename the mv config0.m4 config directly. m4/var/www/php5/bin/phpize. /configure -- with-openssl -- with-php-config =/var/www/php5/bin/php-config make install # After the installation is complete,. so file (openssl. so) directory. Openssl. so file copy to you in php. under extension_dir specified in ini (in php. search for extension_dir = In the INI file. The directory here is var/www/php5/lib/php/extensions # edit php. INI file, add extension = openssl at the end of the file. so # restart Apache and run/usr/local/apache2/bin/apachectl restart. Now openssl support is successfully added. However, Gmail is more troublesome than this. Gmail's current smtp and pop3 are both ssl-encrypted Step1. php openssl module (extension) supportStep2. download phpmailer library3. change Code' class. phpmailer. php 'and' class. smtp. php '1. phpmailer and smtp add property Is_SSL public $ Is_SSL = false; 2. the SmtpConnect method in phpmailer is passed to the smtp object $ this-> smtp-> Is_SSL = $ this-> Is_SSL; 3. before calling fsockopen, add if ($ this-> is_ssl) {$ host = 'ssl: // 'to the Connect Method in smtp ://'. $ host;} is used Method. Remember to call the phpmailer class. The Code does not exist. Copy the code $ mail = new PHPMailer (); $ mail-> IsSMTP (); $ mail-> Host = 'smtp .gmail.com '; // your enterprise Post Office domain name $ mail-> SMTPAuth = true; // turn on SMTP authentication $ mail-> SMTPSecure = "tls "; $ mail-> Username = '*** @ gmail.com'; $ mail-> Password = '******'; $ mail-> From = '***'; $ mail-> FromName = '***'; $ mail-> CharSet = 'utf-8 '; $ mail-> Encoding = "base64"; $ mail-> IsHTML (true); // send as HTML $ mail-> Subject = '***'; // mail title $ mail-> Bod Y = '***'; // email content $ mail-> AltBody = "text/html"; $ mail-> AddAddress ('***',""); $ mail-> Is_SSL = true; $ mail-> Port = 587; if (! $ Mail-> Send () {exit ($ mail-> ErrorInfo);} $ mail-> Smtpclose (); unset ($ mail); copy the code to the Code section, also, do not forget to set it in gmail. After completing the preceding three steps, you can use phpmailer to send gmail emails.

Related Article

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.