[how to] send with Gmail SMTP

Solutions for other phpList version 2 users
Forum rules
Please do not ask questions here, this is for Solutions you have discovered or come across.

Postby emma » 10:14am, Tue 27 May, 2008

Seems that I am still unable to connect to smtp.gmail.com. I can connect outlook to smtp.gmail.com though.
emma
PL Nut
 
Posts: 32
Joined: 7:21am, Tue 05 Feb, 2008

Postby emma » 10:20am, Tue 27 May, 2008

kosir wrote:Is it possible to see more detailed error of what is going on when connecting to smtp server?

I can't figure out why it doesn't work. I setup an account in Outlook and it worked, but phplist won't sent any e-mails.

This are the two errors I get on every send:

Error sending message 11 to some@mail (some@mail)

Mailer Error: SMTP Error: Could not connect to SMTP host.

Doesn't really say much about what is wrong. :s


kosir wrote:Another problem but I guess this is not related to this gmail mod.

I tried to subscriber myself to my newsletter but it failed. This are the errors I see in evetlog

Mailer Error: SMTP Error: Could not connect to SMTP host.

Mailer Error: Language string failed to load: connect_host".

I probably just over looked something and would appreciate if someone could give me some hints.

Thanks!

PS: I am sure I sue correct login infos.


I have the same problems. Both problems are the same and related. See my earlier posts.

Can anyone help kosir and me?
emma
PL Nut
 
Posts: 32
Joined: 7:21am, Tue 05 Feb, 2008

Postby emma » 4:00am, Sat 31 May, 2008

Problem solved. Request your webhost to enable fsockopen() for port 465.
emma
PL Nut
 
Posts: 32
Joined: 7:21am, Tue 05 Feb, 2008

could not be sent?

Postby mrholdem » 9:16pm, Mon 02 Jun, 2008

I have followed the instructions above, and still get a "mail could not be sent to xxx@xxxx"

any ideas?
mrholdem
phpList newbie
 
Posts: 1
Joined: 12:53pm, Mon 02 Jun, 2008

Re: [how to] send with Gmail SMTP

Postby raphaelb » 9:36am, Tue 03 Jun, 2008

I 've ehanced this tip in order to be able to use another port whithout ssl, and to be able to do POP before SMTP auth
bookwish wrote:Phplist and Gmail SMTP

1) Download version 2.0.0 of PHPMailer.

2) Extract this in lists/admin, so you now have a PHPMailer_v2.0.0 directory containing class.phpmailer.php, class.smtp.php, etc. Note that there is an example for Gmail usage (separate from phplist) in docs/use_gmail.txt. (I did not overwrite the old phpmailer directory, because I was not sure initially whether this would work.)

3) Edit the require at the top of lists/admin/class.phplistmailer.php to point to the location of the new class.phpmailer.php, and add a require for the new class.smtp.php (necessary?).


also add it for pop3 class
require_once( dirname(__FILE__) . '/PHPMailer200/class.pop3.php'); // POP before SMTP


4) Still in class.phplistmailer.php, edit the function PHPlistMailer so it looks like:
...
Code: Select all
function PHPlistMailer($messageid,$email) {
    #  parent::PHPMailer();
      parent::SetLanguage('en','phpmailer/language/');
      $this->addCustomHeader("X-Mailer: phplist v".VERSION);
      $this->addCustomHeader("X-MessageID: $messageid");
      $this->addCustomHeader("X-ListMember: $email");
      $this->addCustomHeader("Precedence: bulk");
      $this->Host = PHPMAILERHOST;
      $this->Helo = getConfig("website");
      $this->CharSet = getConfig("html_charset");
//begin EDIT
     if (isset($GLOBALS['phpmailer_smtpport']) && $GLOBALS['phpmailer_smtpport'] != '') {
         if($GLOBALS['phpmailer_smtpport'] == '465'||$GLOBALS['phpmailer_smtpport'] == '995')
            {
            $this->SMTPSecure="ssl";
            }
         $this->Port=$GLOBALS['phpmailer_smtpport'];
      }
      if (isset($GLOBALS['phpmailer_smtpuser']) && $GLOBALS['phpmailer_smtpuser'] != '') {
           $this->SMTPAuth=true;
         $this->Username=$GLOBALS['phpmailer_smtpuser'];
         $this->Password=$GLOBALS['phpmailer_smtppassword'];
#        logEvent('Sending authenticated email via '.PHPMAILERHOST);
      }    
     //end EDIT

...

Further down, change if (!$this->Host || $ip == $this->Host) to if (!$this->Host) (credit).

A few lines down, just below $this->Mailer="smtp", add $this->IsSMTP(); (necessary?).


Further down edit the function send so it looks like
Code: Select all
    function send($to_name = "", $to_addr, $from_name, $from_addr, $subject = '', $headers = '',$envelope = '') {
[color=blue]
      //begin POP before SMTP
      if (isset($GLOBALS['phpmailer_popuser']) && $GLOBALS['phpmailer_popuser'] != '') {
            $pop = new POP3();
            if(!$pop->Authorise(PHPMAILERHOST, 110, 30, $GLOBALS['phpmailer_popuser'], $GLOBALS['phpmailer_poppassword'], 1))
               {
               logEvent('Mailer Error: Auth pop failed');
               return 0;
               }
         }
      //end POP before SMTP

      $this->From = $from_addr;
      $this->FromName = $from_name;

...

5) Edit lists/config/config.php to read
...
define("PHPMAILERHOST",'smtp.gmail.com');
...
for SMTP AUTH
$phpmailer_smtpuser='your mail address';
$phpmailer_smtppassword='your mail password';

to use SSL port(465 or 995) or other port

$phpmailer_smtpport=465;//specific port : SSL (Gmail...)

for POP Before SMTP

$phpmailer_popuser = $bounce_mailbox_user; //or your mail adress like for classical auth
$phpmailer_poppassword = $bounce_mailbox_password; //or your mail password like for classical auth


...
raphaelb
phpLister
 
Posts: 9
Joined: 9:43am, Tue 13 May, 2008

Gmail Fix

Postby bonghitter » 11:07pm, Fri 27 Jun, 2008

Thanks bookwish, that was some helpful info.

I implemented all the fixes in your post, taking note of the subtle typos that we pointed out. Unfortunatley I am running into the same problem as kosir where my /admin and /lists pages are now blank.

I've rechecked the problem ; - and it's there. I fixed the smtp bit in the config's password line.. but nothing?!

The 'require' lines I think I have right:
require( dirname(__FILE__) . '/PHPMailer_v2.0.0/class.phpmailer.php');
require( dirname(__FILE__) . '/PHPMailer_v2.0.0/class.smtp.php');

Anyone else have a similar issue? I don't know whether I should undo these changes now, or try and fix?!?
bonghitter
phpList newbie
 
Posts: 1
Joined: 10:58pm, Fri 27 Jun, 2008

Postby Guest » 6:14pm, Sat 02 Aug, 2008

followed directions and im still ending up with Sent test mail to: xxxx@xxxx{dot}com failed.

i figured maybe the test send was having issues so i sent a blast and got this in the event logs

Mailer Error: SMTP Error: Could not connect to SMTP host.

i know my credentials are correct... please help!
Guest
 

cannot attach files

Postby Guest » 11:10am, Sun 10 Aug, 2008

Thanks bookwish. I followed your instruction and adapted it to work with TLS also. However, I face a problem that when I attached an attachment, recipients didn't see any attachment in HTML mode, however, in text mode, there's a link to dowload that file.

Anyone has this problem or has a solution?

p.s. I'm using PHPList 2.10.5 and I tried with both PHPMailer 2.2.1 and 2.1.
Guest
 

Re: Phplist and Gmail SMTP

Postby Guest » 2:16am, Fri 24 Oct, 2008

Thanks for this, Bookwish. I've been struggling with this for a week since converting everyone over to Google Apps. One run through following your instructions and it finally worked perfectly!
Guest
 

phpmailer 2.3 is available

Postby rrcatto » 3:47am, Sat 06 Dec, 2008

Go here to download the latest phpmailer:
phpmailer . codeworxtech . com

You just need to overwrite the phpmailer php files supplied with the phplist distro with the new phpmailer files.

No need to require the smtp class, that is taken care of by the phpmailer class php file.

Then hack your class.phplistmailer.php file as indicated.

Check that php is compiled with support for OpenSSL or this hack will not work.
rrcatto
phpLister
 
Posts: 9
Joined: 3:41pm, Thu 27 Jul, 2006

Postby Guest » 4:14pm, Fri 23 Jan, 2009

hi all,

I've tried to incorporate this into v2.10.8 but am not having any luck connecting to smtp.

I was wondering if anyone here has managed to use this mod on this version with their gmail settings for smtp?

I've uncommented the error log lines around this mod and get the following reported in the event log.

Sending authenticated email via smtp.gmail.com

Sending via smtp

Mailer Error: Language string failed to load: connect_host

Error sending message 36 to testlist user @ hotmail.com ( testlist user @ hotmail.com )

The above repeats itself for each person on the list.

I downloaded v2.0.0 of PHPMailer and modified class.phplistmailer.php. I already had the smtp values set up in config and have rechecked these. I've successfully tested my gmail settings by adding an account in Outlook and sending a test message from that. I've spoken to my host and confirmed port 465 is open and used telnet to double check and that seems ok.

Any help very much appreciated. I've tried raphaelb and bookwish's versions.
Guest
 

Re: [how to] send with Gmail SMTP

Postby ejb5oh » 6:08am, Tue 14 Apr, 2009

Error I keep Receiving:

Started
Processing has started, 1 message(s) to process.
It is safe to click your "stop" button now, report will be sent by email to admin@mysite.com
Processing message 24
Looking for users
Found them: 2 to process
Processed 2 out of 2 users
Script stage: 5
2 emails failed (will retry later)
Finished this run
Waiting for 3600 seconds before reloading

When I had the error messages coming up, it says that I cannot connect to the SMTP host (gmail).

I am using phplist 2.10.9
my hosting company is Godaddy (linux apache)

I have tried all the various steps here, just cannot get SMTP to connect and send out emails through gmail user apps account.

Any other ideas??
ejb5oh
phpLister
 
Posts: 6
Joined: 5:09am, Fri 03 Apr, 2009

Re:

Postby ejb5oh » 6:10am, Tue 14 Apr, 2009

emma wrote:Seems that I am still unable to connect to smtp.gmail.com. I can connect outlook to smtp.gmail.com though.


Same results here.
ejb5oh
phpLister
 
Posts: 6
Joined: 5:09am, Fri 03 Apr, 2009

Re: [how to] send with Gmail SMTP

Postby ejb5oh » 6:22am, Wed 15 Apr, 2009

Any good tips on the matter? Anyone? It appears that this may be somehow related to the upgrade of this most recent version of phplist, as the last known version to accept the listed updates in this thread were before the 2.10.8 versions.
ejb5oh
phpLister
 
Posts: 6
Joined: 5:09am, Fri 03 Apr, 2009

Re: [how to] send with Gmail SMTP

Postby mahoomeister » 3:25pm, Sat 08 Aug, 2009

Hi,

I've tried everything in this thread and a number of other ones but just cannot seem to get smtp for Google Mail working. Here are my settings:

In config/config.php:

Code: Select all
# To use a SMTP please give your server hostname here, leave it blank to use the standard
# PHP mail() command.
define("PHPMAILERHOST",'smtp.gmail.com');

# if you want to use smtp authentication when sending the email uncomment the following
# two lines and set the username and password to be the correct ones
$phpmailer_smtpuser = 'no-reply@mydomain.com';
$phpmailer_smtppassword = 'mypassword';
$phpmailer_smtpport = '465';


Note: I've also tried using "ssl://smtp.gmail.com" for "PHPMAILERHOST" and get an error:
SMTP -> ERROR: Failed to connect to server: () Sent test mail to: testing@mydomain.com failed

In admin/class.phplistmailer.php

Code: Select all
    function PHPlistMailer($messageid,$email) {
    #  parent::PHPMailer();
      parent::SetLanguage('en', dirname(__FILE__) . 'phpmailer/language/');
      $this->addCustomHeader("X-Mailer: phplist v".VERSION);
      $this->addCustomHeader("X-MessageID: $messageid");
      $this->addCustomHeader("X-ListMember: $email");
      $this->addCustomHeader("Precedence: bulk");
      $this->Host = PHPMAILERHOST;
      //$this->Helo = getConfig("website");
      $this->Helo = getConfig("PHPMAILERHOST");
      $this->CharSet = getConfig("html_charset");
      if (isset($GLOBALS['phpmailer_smtpuser']) && $GLOBALS['phpmailer_smtpuser'] != '') {
        $this->SMTPAuth = true;
        $this->Username = $GLOBALS['phpmailer_smtpuser'];
        $this->Password = $GLOBALS['phpmailer_smtppassword'];
   $this->Port    = $GLOBALS['phpmailer_smtpport'];
#        logEvent('Sending authenticated email via '.PHPMAILERHOST);
      }
      $ip = gethostbyname($this->Host);
      if ($GLOBALS["message_envelope"]) {
        $this->Sender = $GLOBALS["message_envelope"];
        $this->addCustomHeader("Errors-To: ".$GLOBALS["message_envelope"]);
      }
      //if (!$this->Host || $ip == $this->Host) {
        //$this->Mailer = "mail";
#        //logEvent('Sending via mail');
      //} else {
        $this->Mailer = "smtp";
#        logEvent('Sending via smtp');
     // }
    }


I've also enable debugging / smtp debugging. When I attempt to send a message I get the following error:
Code: Select all
Message saved

SMTP -> FROM SERVER: SMTP -> FROM SERVER: SMTP -> ERROR: EHLO not accepted from server: SMTP -> FROM SERVER: SMTP -> ERROR: HELO not accepted from server: SMTP -> ERROR: AUTH not accepted from server: SMTP -> NOTICE: EOF caught while checking if connectedSent test mail to: testing@mydomain.com failed


I know Google Mail SMTP works on/from our server because I use it in osCommerce to send mails from an online store (different business)! Anybody any ideas? Thanks in advance.

- Mahoo
mahoomeister
phpList newbie
 
Posts: 3
Joined: 2:05pm, Sat 08 Aug, 2009

PreviousNext

Return to Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 2 guests