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

[how to] send with Gmail SMTP

Postby bookwish » 10:20pm, Mon 31 Mar, 2008

I was not able to find a solution here that enabled me to send messages with Gmail SMTP, using phplist 2.10.5. Various advice is offered in the forums, and some of it seems to have worked for some people, but none of it worked (entirely) for me. So, I wrote a brief explanation of what I finally did that worked, with the intention of posting here, but the restriction on new users posting URLs prevented me from doing so (I even mangled the URLs several different ways, to no avail -- maybe the code was causing a problem?). So, I have posted it on my site at bookwish o-r-g (slash) phplist-and-gmail-smtp.

[[Edited by moderator to include Bookwish's full instructions below:]]


Phplist and Gmail SMTP

We just moved bookwish.org to a new host, and, in the process, switched our mailserver to Gmail SMTP. Unfortunately, our mailing list software, phplist, was not Gmail SMTP-capable, without a few minor modifications. For the benefit of other phplist users, here is what I did to get phplist 2.10.5 to send mail through 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?).

4) Still in class.phplistmailer.php, edit the function PHPlistMailer so it looks like:
...
if (isset($GLOBALS['phpmailer_smtpuser])...
$this->SMTPAuth=true;
$this->SMTPSecure="ssl";
$this->Port=$GLOBALS['phpmailer_smtpport'];
$this->Username=$GLOBALS['phpmailer_smtpuser'];
$this->Password=$GLOBALS['phpmailer_smtppassword'];

...

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?).

5) Edit lists/config/config.php to read
...
define("PHPMAILERHOST",'smtp.gmail.com');
...
$phpmailer_smtpuser='your Gmail address';
$phpmailer_smtppassword='your Gmail password';
$phpmailer_smtpport=465;

...

The above works for me, but I have not attempted to provide the most general solution or the simplest one. I stopped investigating, once I found a solution for my setup. Use at your own risk.

If you find this helpful, please consider linking to www.bookwish.org or mentioning us in your now-Gmail-enabled newsletters. We are a nonprofit with a mission to provide reading relief for people in crisis (e.g., our project focused on Darfur refugees in eastern Chad includes secondary school books, library construction, reading glasses, etc.).
bookwish
phpList newbie
 
Posts: 3
Joined: 8:02pm, Mon 31 Mar, 2008

Postby WinstonN » 3:17pm, Wed 02 Apr, 2008

Well done, your post rocks!

Can you tell me the amount of emails you send via Gmail? How many of them arrive? and do you use any throttling on the mailing?

Sorry for the 20 questions, but I tried this before and none of my mails arrived :lol:

I figured Google must just be dropping them based on a header somewhere,

Thanks in advance for your response,
All the best,
Wins
Winston Nolan
http://www.buyxonline.com
eCommerce and Email Marketing
WinstonN
PL Master
 
Posts: 158
Joined: 3:31pm, Sun 04 Feb, 2007
Location: Cape Town, South Africa

Postby bookwish » 3:26pm, Wed 02 Apr, 2008

Thanks, glad to be of help. Have not had a problem with emails not arriving. Usually send less than 100 at a time, without throttling.

For the messages that did not arrive, did you check your Gmail Sent Mail folder to make sure they were sent?
bookwish
phpList newbie
 
Posts: 3
Joined: 8:02pm, Mon 31 Mar, 2008

Postby WinstonN » 3:59pm, Wed 02 Apr, 2008

What I saw on my system was the mails leaving, and google picking them up giving me 250 OK's but I never saw anything after that, not in my send items or anywhere. So at this stage I figured ok, well maybe Google blocked it.

Will definitely look into it again,

Thanks and all the best,
Wins
Winston Nolan
http://www.buyxonline.com
eCommerce and Email Marketing
WinstonN
PL Master
 
Posts: 158
Joined: 3:31pm, Sun 04 Feb, 2007
Location: Cape Town, South Africa

Postby kosir » 12:07pm, Tue 08 Apr, 2008

Hello!

Thanks for this great mod it really helped me.

But after I did everything like you wrote I got a blank page for both my admin and main newsletter page.

After a recheck of what I did to make phplist work with gmail I noticed that there is a ; missing after "$this->IsSMTP()" in step 4. After adding this ; my newsletter came back to life.

Thanks again for this mod.
kosir
phpList newbie
 
Posts: 3
Joined: 11:39am, Tue 08 Apr, 2008

Postby Dragonrider » 12:20pm, Tue 08 Apr, 2008

kosir wrote:After a recheck of what I did to make phplist work with gmail I noticed that there is a ; missing after "$this->IsSMTP()" in step 4. After adding this ; my newsletter came back to life.



Corrected, thanks for spotting that! :D
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

Postby kosir » 1:57pm, Tue 08 Apr, 2008

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.
Last edited by kosir on 11:38pm, Tue 08 Apr, 2008, edited 1 time in total.
kosir
phpList newbie
 
Posts: 3
Joined: 11:39am, Tue 08 Apr, 2008

Postby kosir » 12:56pm, Wed 09 Apr, 2008

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
phpList newbie
 
Posts: 3
Joined: 11:39am, Tue 08 Apr, 2008

Small error found...

Postby quidware » 1:36am, Wed 23 Apr, 2008

I finally GOT IT WORKING!!!

It's amazing!!

Well the error that I found (which made me trouble for some minutes) is in the last step:

This:
Code: Select all
$phpmailer_smtpuser='your Gmail address';
$phpmailer_password='your Gmail password';
$phpmailer_smtpport=465;


SHOULD BE:
Code: Select all
$phpmailer_smtpuser='your Gmail address';
$phpmailer_smtppassword='your Gmail password';
$phpmailer_smtpport=465;


You can see the obvious mistake:

phpmailer_smtppassword

THAT?S IT!!! Great! thanks

See ya, now I need to check the bouncing.
quidware
phpLister
 
Posts: 7
Joined: 8:17pm, Fri 18 Apr, 2008
Location: QRO, MX

One more thing... Configure for gmail...

Postby quidware » 4:38am, Wed 23 Apr, 2008

One more thing...

I discovered that using gmailDOTcom (I couldn't place a real DOT because of this forum policies, YOU SHOULD PUT A REAL DOT) as Domain Name of your server (for email) in your PHPList normal configuration , helps to avoid being recognized as spam in Hotmail. EVENTHOUGH you are using GApps!

Maybe it will help to avoid spam folder in many other mail sytems too, so I recomend to use it. Basically it changes not much, but the receiver server does.

I really hope NO spamers are reading this.

PS: If you change this, check out your other mails in the configuration, some may change to gmailDOTcom, just correct them.
quidware
phpLister
 
Posts: 7
Joined: 8:17pm, Fri 18 Apr, 2008
Location: QRO, MX

typo

Postby bookwish » 2:07pm, Wed 23 Apr, 2008

Quidware is correct, there is a typo: $phpmailer_password should be $phpmailer_smtppassword. I cannot edit the post to reflect this, because of the anti-spamming restrictions here (the admin previously edited to add content I cannot add), but please note that you should make this correction.

Thanks, quidware!

== EDIT by moderator: correction applied to the first post. And thanks to all for supporting this thread! H2B2.
bookwish
phpList newbie
 
Posts: 3
Joined: 8:02pm, Mon 31 Mar, 2008

Pop3 WITH GMAIL has no solution at all? FALSE...

Postby quidware » 3:27am, Thu 24 Apr, 2008

I was very determinant. If others have got the things to work fine, I should be able too.

If you have trouble with the Pop3 (for the Bounces), and you have already tried all the possibilities in this topic (or the other ones of Gmail and PHP List)...

TRY THIS...

Ask your host-manager or support technicians to check that your Port 995 is open for outgoing connections. My support area said it was ok, but they "restarted the firewall-just to be sure" , and JAY!! Like a CHARM!

YES, for some it may be a big deal or complicated thing, because it may not be of just a few minutes, but if that solved my problem, maybe it will with your's too. The simplest code now works fine.

## P S :
How I got there? Easy, making a very specific searching in google, and found in PHPClasses ORG a thread about Manuel Lemo's Pop3-email-client-Class and read this as an answer of support technician to someone with problems...
---
Port 995 was open for incoming connections but not for outgoing ones which has been opened now and your script is working fine now.
---

CHEERS!
quidware
phpLister
 
Posts: 7
Joined: 8:17pm, Fri 18 Apr, 2008
Location: QRO, MX

Re: [how to] send with Gmail SMTP

Postby emma » 8:25am, Tue 27 May, 2008

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



in sendemaillib.php around line 550, IsSMTP() could be found. If this is enabled, is it still necessary to add the above?

} else {
$mail = new PHPlistMailer($messageid,$destinationemail);
# $mail->IsSMTP();
}
emma
PL Nut
 
Posts: 32
Joined: 7:21am, Tue 05 Feb, 2008

Postby emma » 8:34am, Tue 27 May, 2008

I receive the following error when I tried to subscribe:



Sorry, sending the email to request your confirmation failed, please click "Reload" to try again. If it still does not work, it may be because you are listed on our "Black List", which means that you cannot receive emails from our newsletter system. In that case, please contact the administrator.
emma
PL Nut
 
Posts: 32
Joined: 7:21am, Tue 05 Feb, 2008

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

emma wrote:Sorry, sending the email to request your confirmation failed, please click "Reload" to try again. If it still does not work, it may be because you are listed on our "Black List", which means that you cannot receive emails from our newsletter system. In that case, please contact the administrator.


This error is a result of not being able to connect to gmail. Refer to subscribelib2.php

Code: Select all
  if ($sendrequest && $listsok) {
  #is_array($_POST["list"])) {
    if (sendMail($email, getConfig("subscribesubject:$id"), $subscribemessage,system_messageheaders($email),$envelope,1)) {
      sendAdminCopy("Lists subscription","\n".$email . " has subscribed\n\n$history_entry");
      addUserHistory($email,$history_subject,$history_entry);
      print $thankyoupage;
     } else {
      print '<h3>'.$strEmailFailed.'</h3>';
      if ($blacklisted) {
        print '<p>'.$GLOBALS["strYouAreBlacklisted"].'</p>';
      }
    }
  } else {


emma
PL Nut
 
Posts: 32
Joined: 7:21am, Tue 05 Feb, 2008

Next

Return to Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 4 guests

cron