Phplist and Phpmailer (combined) how to send mail via Gmail, phplistphpmailer_php tutorial

Source: Internet
Author: User
Tags word wrap how to send mail gmail password

Phplist and Phpmailer (combined use) the configuration method of sending mail via Gmail, Phplistphpmailer


This example describes how phplist and phpmailer send mail via gmail. Share to everyone for your reference, as follows:

In general, as long as you are not using Gmail mailbox, then use Phplist to send mail as long as the previous "PHP bulk mail system phplist Configuration Method Detailed Summary" configuration is enough. But if you are as unfortunate as me, you must use the Gmail SSL authentication mailbox, then congratulations, my misfortune has now become your lucky, after a few days of trying, I finally succeeded in combining Gmail with Phplist. I would like to share my experience with you and hope to be useful to the comrades in my general situation. In addition, the core of Phplist is Phpmailer, I propose the solution is mainly around Phpmailer, so I need to use Phpmailer to send mail through Gmail but not successful people can also refer to my method.

First, in accordance with the "PHP bulk mail system phplist Configuration Method Detailed Summary" in the configuration method via Gmail to send mail, when sending a test message phplist will report the sending of the message failed, in the event log (eventlog) there will be an error "Mailer" errors: The following from address failed: ... ", which says there is a problem with the sender addresses. Is the SMTP server already connected, but there is a problem with sending the message? You can use a method to test if the connection is not connected to the SMTP server: I put the config.php file in the mailbox account password was deliberately wrong, the result of sending a test message still reported the same error, it appears that the SMTP server is not connected, this Phplist error report is too ...

Know it's not connected to the SMTP server. That means the problem is at the heart of Phplist's sending email-another famous open-source software Phpmailer.

On the internet to check the Phpmailer send Gmail messages, found that people say the old version of Phpmailer does not support SSL authentication, can not connect to Gmail's SMTP server, and this issue has been resolved in the new version of Phpmailer.

Open Lists/admin/phpmailer/changelog.txt, found that the latest version of the phplist comes with the Phpmailer version is 1.73, is 2005 out, really not new. So on Phpmailer's official website under a new 5.1.

I want to first study how the new version of Phpmailer is to solve the problem of SSL authentication, and then looked at some of its own documentation, it happened to find a use_ under the Phpmailer_v5.1/docs Gmail.txt, it seems that the official more attention to Gmail problem, specifically a demo for people to reference. Open a look is also really a full php page file, basically modify the file name extension, mailbox user name and password can be used, but if only so modified, in the access to the test page will be an error, I do not know the official demo how there is such a mistake, actually call an undefined function, And there are some unnecessary ingredients. We just wanted to test the ability to send the message as expected, so I changed it to:

<?php//example on using Phpmailer with GMAIL include ("class.phpmailer.php"); Include ("class.smtp.php");    Note, this was optional-gets called from main class if not already loaded $mail = new Phpmailer ();    $body = "Test";    $mail->issmtp ();         $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 $mail->username = "myname@gmail.com";      GMAIL username $mail->password = "MyPassword";    GMAIL password $mail->from = "myname@gmail.com";    $mail->fromname = "Webmaster";    $mail->subject = "This is the Subject"; $mail->altbody = "The body when user plain text format"; Text Body $mail->wordwrap = 50;    Set word wrap $mail->msghtml ($body); $mail->addreplyto("Myname@gmail.com", "Webmaster");    $mail->addaddress ("myname@gmail.com", "First Last"); $mail->ishtml (TRUE); Send As HTML if (! $mail->send ()) {echo "Mailer Error:".    $mail->errorinfo;    } else {echo "Message has been sent"; }?>

The results found that access to this page still error, it is very frustrating, the official demo how can not run?

At this time I suddenly think of Phpmailer_v5.1/docs under a file called Note_for_smtp_debugging.txt, now I am not in order to connect to the SMTP server and worry about it, may wish to look at the debugging method provided inside.

Open the file after reading the first line on the bright, this is what I need! In fact, the use of the method is very simple, as long as

$mail->issmtp ();

Front insert

$mail->smtpdebug = 1;

You can get a more detailed error message at the same time. That's a good thing ^_^.

Following this modification, I got a more detailed description of the page when I visited it--"SMTP-error:failed to connect to server:unable to find the socket transport" SSL "-di D You forget to enable it when do you configured PHP? (28593608) ".

So I opened my php config file (c://windows/php.ini) to search for SSL, and I found an extension of SSL.

; Extension=php_openssl.dll

It was not opened. Remove the ";" before it is used for comments, and then restart the server again to access the test page use_gmail.php, which is still the same error message.

No way, I went online to check the PHP and Apache SSL configuration article, found that only the SSL extension is not enough to open, but also to configure OpenSSL, in the Windows environment configuration method is very simple-- Locate the Ssleay32.dll and Libeay32.dll in the PHP installation directory, and copy both to the System32 directory under Windows (Extension=php_openssl.dll is enabled in php.ini). Of course, the comrades who do not want to "pollute" the System32 directory can use the method of modifying the environment variables, so long as the Ssleay32.dll and Libeay32.dll are in the system path. (If you're not using the Winidows operating system, check the Internet to find out how to configure SSL for your operating system, which should not be difficult to find)

This time again visit use_gmail.php Discovery can be sent successfully!

On this basis, our phplist problem can also be solved: with the new version Phpmailer class.phpmailer.php and class.smtp.php overwrite the corresponding file in Lists/admin/phpmailer, Then modify the lists/admin/class.phplistmailer.php in the left and right of the 36

$this->smtpauth = true; $this->helo = GetConfig ("website"); $this->host = Phpmailerhost;

For:

$this->issmtp ();            # Add$this->smtpauth = true; $this->smtpsecure = "SSL";       # Add$this->helo = getconfig ("website"); $this->host = phpmailerhost; $this->port = 465            # ADD

Where the Phpmailer default port number is 25, is the port number for most SMTP servers, but Gmail uses a port number of 465, so you have to reset it.

More interested in PHP related content readers can view this site: "PHP Network Programming Skills Summary", "PHP Basic Grammar Introductory Tutorial", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", " PHP Date and Time usage summary, PHP Object-oriented Programming primer, PHP string usage Summary, PHP+MYSQL Database Operations Primer, and PHP Common database operations Tips Summary

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • A detailed summary of Phplist configuration method for bulk mail system in PHP
    • PHP sends mail with Phpmailer
    • thinkphp how to send mail using Phpmailer
    • Use Phpmailer to send code sharing for mail
    • Phpmailer the solution for sending mail on the server is not normal
    • Phpmailer Sending HTML content, message instances with attachments
    • The solution of Phpmailer Chinese garbled problem
    • A simple way to use PHP to send mail using Phpmailer
    • thinkphp implementing code for mail delivery using Phpmailer
    • Phpmailer Send an example of Gmail messages
    • Phpmailer implementation code for mail delivery

http://www.bkjia.com/PHPjc/1117064.html www.bkjia.com true http://www.bkjia.com/PHPjc/1117064.html techarticle Phplist and Phpmailer (combined use) the configuration method of sending mail via Gmail, Phplistphpmailer This article describes how phplist and Phpmailer are configured to send mail via Gmail. Share to the big ...

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