Summary phpmailer mass gmail FAQ, Phpmailer mass gmail_php tutorial

Source: Internet
Author: User
Tags gmail mail gmail password

Summary phpmailer mass gmail FAQ, Phpmailer mass gmail


Everyone in Phpmailer mass Gmail will encounter many common problems, the following for you to summarize some common problems, I hope that everyone's learning has helped.

1.Could not authenticate

First of all, if you do not use the loop, basically is the account or password is wrong;

If you use a loop to mass, remember to call Smtpclose () after the Send () method ends, or you can send a message once, or you will get a crash on the second time.

2.Gmail

First, turn on SSL permissions for PHP

PHP opens the OpenSSL method, in most cases, OpenSSL is not turned on, to enable the need to make the following simple settings:

windows open Method:

1: first check the php.ini; Extension=php_openssl.dll exists, if present, remove the previous comment '; ', if it does not exist, add Extension=php_openssl.dll.

2: Speak the PHP folder under: Php_openssl.dll, Ssleay32.dll, Libeay32.dll 3 files copied to the Windows\system32\ folder.

3: Restart Apache or IIS

At this point, the OpenSSL function is turned on.

Linux under Open method:

I am using the Brocade Data Cloud Host, PHP version: 5.2.14

The following scenario takes my host as an example to add the OpenSSL module support for PHP.

Some of the online answers say to recompile PHP, add configure parameters, and increase the support of OpenSSL. Here is a method that does not require recompilation.

If the server exists PHP installation package files Best, if you have deleted, go to download and Phpinfo page display version of the same PHP installation files, I here is php-5.2.14.tar.gz

Recommended to Sohu image download, NetEase image not found. Address: http://mirrors.sohu.com/php/

Connect to the host using the SSH tool.

# download to the/VAR/WWW/PHP5 directory Cd/var/www/php5wget http://mirrors.sohu.com/php/php-5.2.14.tar.gz# unzip the tar zxvf php-5.2.14.tar.gz# enter PHP's OpenSSL Extension Module catalog CD Php-5.2.14/ext/openssl//var/www/php5/bin/phpize # Here for your own phpize path, if not found, After using Whereis phpize find # Execution, find the error cannot find CONFIG.M4, CONFIG0.M4 is config.m4. Directly rename MV config0.m4 config.m4/var/www/php5/bin/phpize./configure--with-openssl--with-php-config=/var/www/php5/bin /php-configmakemake install# a directory of. so files (openssl.so) is returned when the installation is complete. In this directory, copy the openssl.so file to the extension_dir you specified in php.ini (find in the php.ini file: Extension_dir =), my directory here is var/www/php5/lib/php/ extensions# edit php.ini file, add extension=openssl.so# at the end of the file to restart Apache/usr/local/apache2/bin/apachectl restart

OK, now you have successfully added OpenSSL support.

However, Gmail's trouble is more than that, Gmail now SMTP and POP3 are SSL-encrypted

Step1. PHP OpenSSL module (extension) support
Step2. Download Phpmailer Library
Step3. Change code ' class.phpmailer.php ' and ' class.smtp.php '

1.phpmailer and SMTP Riga property Is_ssl

Public $Is _ssl = false;

The Smtpconnect method in 2.phpmailer is passed to the SMTP object

$this->smtp-> Is_ssl = $this, Is_ssl;

The Connect method in 3.SMTP is preceded by a fsockopen call.

if ($this->is_ssl) {$host = ' ssl://'. $host;}

Finally, the use of the method, remember to call the Phpmailer class Oh, the code does not.

$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 = ' * * * '; Message title $mail->body = ' * * * '; Mail content $mail->altbody = "text/html"; $mail->addaddress (' * * * ', ""); $mail->is_ssl = true; $mail->port = 587;if (! $mail->send ()) {  exit ($mail->errorinfo);} $mail->smtpclose (); unset ($mail);

This is part of the code, and don't forget to set it up in Gmail.

The above three steps completed, you can freely use Phpmailer to send Gmail mail.

And then we'll share a phpmailer. Send a Gmail message instance:

<title>PHPMAILER-SMTP (Gmail) Basic test</title><?php//error_reporting (E_all), error_reporting (e_strict);d ate_default_timezone_set (' America/Toronto '); 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_con Tents (' contents.html '); $body = Eregi_replace ("[\]" "," ', $body); $mail->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, please use 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!";}? > 

The above is the whole content of this article, I hope that everyone's study has helped.

Articles you may be interested in:

    • PHP get 163, Gmail, 126 mailbox Contact address "tested 2009.10.10"
    • PHP analog Gmail,hotmail (MSN), yahoo,163,126 mailbox Login Details
    • PHP implementation of bulk mail source
    • Phpmailer Send an example of Gmail messages
    • Java, PHP, C #, ASP to realize the method of mass message function
    • PHP implementation of the public number unlimited mass
    • Php+swoole realizes simple multiplayer online chat mass.
    • PHP Mail Bulk Machine Implementation code

http://www.bkjia.com/PHPjc/1104341.html www.bkjia.com true http://www.bkjia.com/PHPjc/1104341.html techarticle summary phpmailer Mass Gmail frequently asked questions, Phpmailer mass gmail everyone in the Phpmailer mass Gmail will encounter many common problems, the following summarizes a number of common problems, I hope the big ...

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