Using smtp2go with PHPList

Hi guys,
I’m trying to use smtp2go with my phplist installation (cheaper than buying more relays) yet I’m not able to setup my phplist with it, I followed their guide Setting up PHPList with SMTP2GO but no luck, the support there then asked me to try all their different ports, which i did : port number 8025, 587, 80 or 25 with TLS
My max_execution_time is set to 120 in php.ini (user.ini).

My smtp settings are :

// you can specify the location of the phpMailer class here
// if not set, the version included in the distribution will be used
//# eg for Debian based systems, it may be something like the example below
//# when you do this, you may need to run some tests, to see if the phpMailer version
//# you have works ok
//define (‘PHPMAILER_PATH’,‘/usr/share/php/libphp-phpmailer/class.phpmailer.php’);
// or a more recent version of phpMailer will be like this
//define (‘PHPMAILER_PATH’,‘/usr/share/php/libphp-phpmailer/PHPMailerAutoload.php’);

// To use a SMTP server please give your server hostname here, leave it blank to use the standard
// PHP mail() command.
define(‘PHPMAILERHOST’, ‘mail.smtp2go.com’);

// in the above you can specify multiple SMTP servers like this:
// ‘server1:port1;server2:port2;server3:port3’ eg
//define(‘PHPMAILERHOST’,‘smtp1.mydomain.com:25;smtp2.mydomain.com:2500;smtp3.phplist.com:5123’);

// 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 = ‘web@.ie’;
$phpmailer_smtppassword = '
*’;

//# you can set this to send out via a different SMTP port
define(‘PHPMAILERPORT’,587);

Below is my event log from PHPList. I was hoping someone might be able to say oh yeah this is it.

Thanks very much,
Karen


797083 23 June 2017 04:08:53 select id from phplist_message where status not in (“draft”, “sent”, “prepared”, “suspended”) and embargo
797084 23 June 2017 04:08:53 Processing has started,
797085 23 June 2017 04:08:53 One campaign to process.
797086 23 June 2017 04:08:53 Please leave this window open. phpList will process your queue until all messages have been sent. This may take a while
797087 23 June 2017 04:08:53 Report of processing will be sent by email
797088 23 June 2017 04:08:53 sending of this campaign will stop, if it is still going in 173 days 12 hours 51 minutes 07 seconds
797089 23 June 2017 04:08:57 Error sending email to web@adlantic.ie SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
797090 23 June 2017 04:08:57 Processing message 43
797091 23 June 2017 04:08:57 Looking for subscribers
797092 23 June 2017 04:08:57 User select query select distinct u.id from phplist_listuser as listuser inner join phplist_user_user as u ON u.id = listuser.userid inner join phplist_listmessage as listmessage ON listuser.listid = listmessage.listid left join phplist_usermessage as um ON (um.messageid = 43 and um.userid = listuser.userid) where listmessage.messageid = 43 and listmessage.listid = listuser.listid and u.id = listuser.userid and um.userid IS NULL and u.confirmed and !u.blacklisted and !u.disabled
797093 23 June 2017 04:08:57 Found them: 0 to process
797094 23 June 2017 04:08:57 Processed 0 out of 0 subscribers
797095 23 June 2017 04:08:57 Hmmm, No subscribers found to send to
797096 23 June 2017 04:09:01 Error sending email to web@adlantic.ie SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
797097 23 June 2017 04:09:01 It took very little time to send this message

@MsKazza Your config file does not appear to set the secure option. Also the smtp2go changes seem to be using an old config file so are not correct

define(‘PHPMAILER_SECURE’, ‘tls’);

the config file is from the latest 3.3.1, i changed settings myself and define(“PHPMAILER_SECURE”,‘ssl’); doesn’t work either with the appropriate ports, this is a line taken directly from the config.php for 3.3.1. What do you mean it does not appear to set the secure option?

The config settings in your first post didn’t set PHPMAILER_SECURE.
You should enable smtp debug then send a test message. The debug output, at the top of the page, might explain what is wrong.

with help from smtp2go, this is the latest version of my config file, still no luck.

Message sending options

  • phpList now only uses phpMailer for sending, but below you can
  • tweak a few options on how that is done

=========================================================================

*/

// you can specify the location of the phpMailer class here
// if not set, the version included in the distribution will be used
//# eg for Debian based systems, it may be something like the example below
//# when you do this, you may need to run some tests, to see if the phpMailer version
//# you have works ok
//define (‘PHPMAILER_PATH’,‘/usr/share/php/libphp-phpmailer/class.phpmailer.php’);
// or a more recent version of phpMailer will be like this
//define (‘PHPMAILER_PATH’,‘/usr/share/php/libphp-phpmailer/PHPMailerAutoload.php’);

// To use a SMTP server please give your server hostname here, leave it blank to use the standard
// PHP mail() command.
define(“PHPMAILER”,1);
define(‘PHPMAILERHOST’,‘mail.smtp2go.com’);

// in the above you can specify multiple SMTP servers like this:
// ‘server1:port1;server2:port2;server3:port3’ eg
//define(‘PHPMAILERHOST’,‘smtp1.mydomain.com:25;smtp2.mydomain.com:2500;smtp3.phplist.com:5123’);

// 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 = ‘web@adlantic.ie’;
$phpmailer_smtppassword = ‘*********’;

//# you can set this to send out via a different SMTP port
define(‘PHPMAILERPORT’,25);

//# test vs blast
// you can send test messages via a different SMTP host than the actual campaign queue
// if not set, these default to the above PHPMAILERHOST and PHPMAILERPORT
// define(‘PHPMAILERTESTHOST’,‘testsmtp.mydomain.com’);
// define(‘PHPMAILERBLASTHOST’,‘livesmtp.mydomain.com’);
// define(‘PHPMAILERBLASTPORT’,25);

// to use SSL/TLS when sending set this value
// it can either be “ssl” or “tls” or false to not use SSL/TLS at all
define(“PHPMAILER_SECURE”,‘ssl’);

$phpmailer_smtpport = ‘25’;
// 8025, 587 and 25 can also be used
$phpmailer_smtpsecure = ‘ssl’;
//# SMTP debugging
// Enable debugging output by phpmailer when sending test emails
// See https://phpmailer.github.io/PHPMailer/classes/PHPMailer.html#property_SMTPDebug
define(‘PHPMAILER_SMTP_DEBUG’, 0);

//# Smtp Timeout
//# If you use SMTP for sending, you can set the timeout of the SMTP connection
//# defaults to 5 seconds
// define(‘SMTP_TIMEOUT’,5);

/*

According to smtp2go you have a few values incorrectly set. Now I don’t use smtp2go so I’m looking at my working config.php file that uses my own web server to send out emails.

In phpList 3.3.1 config files it looks like you no longer need to include define(“PHPMAILER”,1); so comment that line out (add //) to the start of the line.

Both of these appear to wrong according to the smtp2go guide:
$phpmailer_smtpport = ‘25’;
// 8025, 587 and 25 can also be used
$phpmailer_smtpsecure = ‘ssl’;
They should be:
$phpmailer_smtpport = ‘2525’;
// 8025, 587 and 25 can also be used
$phpmailer_smtpsecure = ‘tls’;
I’m not 100% sure about the 2525, it could be right or it could be a typo?? I suggest you try it and see.

You don’t mention if you’ve done steps 3 & 4, ie: amending the core code in /lists/admin/class.phplistmailer.php
(Not recommended as you’ll have to change it back after each phpList update).

Thank you for your reply, I did follow thier guide exactly, including changing the other two files, however after it didn’t work their customer support suggested i change it to 25 on ssl. I was able to connect to that on telnet using my username and password, so they think it must be something wrong with the phplist end.
below is the latest log of events after commenting out the define phpmailer, 1.

797224 3 July 2017 03:44:35 select id from phplist_message where status not in (“draft”, “sent”, “prepared”, “suspended”) and embargo
797225 3 July 2017 03:44:35 Processing has started,
797226 3 July 2017 03:44:35 One campaign to process.
797227 3 July 2017 03:44:35 Please leave this window open. phpList will process your queue until all messages have been sent. This may take a while
797228 3 July 2017 03:44:35 Report of processing will be sent by email
797229 3 July 2017 03:44:35 sending of this campaign will stop, if it is still going in 163 days 13 hours 15 minutes 25 seconds
797230 3 July 2017 03:44:39 Error sending email to web@adlantic.ie SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
797231 3 July 2017 03:44:39 Processing message 43
797232 3 July 2017 03:44:39 Looking for subscribers
797233 3 July 2017 03:44:39 User select query select distinct u.id from phplist_listuser as listuser inner join phplist_user_user as u ON u.id = listuser.userid inner join phplist_listmessage as listmessage ON listuser.listid = listmessage.listid left join phplist_usermessage as um ON (um.messageid = 43 and um.userid = listuser.userid) where listmessage.messageid = 43 and listmessage.listid = listuser.listid and u.id = listuser.userid and um.userid IS NULL and u.confirmed and !u.blacklisted and !u.disabled
797234 3 July 2017 03:44:39 Found them: 0 to process
797235 3 July 2017 03:44:39 Processed 0 out of 0 subscribers
797236 3 July 2017 03:44:39 Hmmm, No subscribers found to send to
797237 3 July 2017 03:44:44 Error sending email to web@adlantic.ie SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
797238 3 July 2017 03:44:44 It took very little time to send this message

I should mention that I was able to connect telnet from my computer however phplist is hosted on a godaddy server, could that have anything to do with it? I had been using this same installation of phplist on godaddy, its only when i tried to use smtp2go that it stopped working

@MsKazza You don’t need to make any changes to the phplist code. The smtp2go guide applies to a much older version of phplist. All you need to do is set these values in your config.php file

define("PHPMAILERHOST",'mail.smtp2go.com');
$phpmailer_smtpuser = 'xxx';
$phpmailer_smtppassword = 'yyyy';
define('PHPMAILERPORT',587);
define("PHPMAILER_SECURE",'tls');

then enable smtp debugging

define('PHPMAILER_SMTP_DEBUG', 3);

and send a test message from the Compose page. There will be some debug output at the top of the page which should explain why it is not working.

@MsKazza Many shared hosting providers, reportedly including GoDaddy, block standard SMTP ports (including 587) and require you to use an external service as a mail relay. That may be an issue.

Thank you both for your replies, i tried reuploading a clean version of phplist and only changed as you mentioned duncanc, still no joy. I also spoke to godaddy customer service according to the one i spoke with port 465 should work on ssl however it doesn’t, no surprise there. I have tried turning on the debugging, however i can’t see where it comes up. I go into system and log of events that is the only error info i see is that what the debugging option enables? when i try to send a campaign any text rushes by so far it can’t be read, i talking half a second here. And then it just says all done.

I explained previously how to use smtp debug[quote]
then enable smtp debugging

define(‘PHPMAILER_SMTP_DEBUG’, 3);

and send a test message from the Compose page. There will be some debug output at the top of the page which should explain why it is not working.
[/quote]

ahhh i thought it was from the box when you click send campaign, didn’t realize you meant the send a test.

This is what came up:

Connection: opening to ssl://mail.smtp2go.com:465, timeout=20, options=array ()
Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): unable to connect to ssl://mail.smtp2go.com:465 (Connection refused)
SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Thanks,
Karen

@MsKazza The smtp2go guide doesn’t seem to mention using ssl with port 465.

You should try tls with port 587, or the other ports that are mentioned - 25, 8025 and 2525 but I expect that godaddy will have blocked those.

sorry i should have said i got the below from smtp2go support:

(SMTP2GO Support)
13 Jul, 16:38 NZST

Hi,
I’ve spent some time installing PHPList on non SMTP2GO and non GoDaddy webserver. I was able to send email using port 465 and having the SSL setting turned on.

I used these settings in the config_extended.php file:

define(‘PHPMAILERHOST’, ‘mail.smtp2go.com:465’);

define(“PHPMAILER_SECURE”,‘ssl’);

I left the custom port commented out as it can be included in the “PHPMAILERHOST” setting.

@MsKazza Please try the tls port 587 method then show the result.

Connection: opening to mail.smtp2go.com:587, timeout=20, options=array ()
Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): unable to connect to mail.smtp2go.com:587 (Connection refused)
SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

going to call godaddy again now, i can connect to these ports from our work network using telnet so must be godaddy

@MsKazza yes it appears that Godaddy is blocking those ports.

On my local phplist I can connect to mail.smtp2go.com on port 587, it then fails on the authentication.

define("PHPMAILERHOST",'mail.smtp2go.com');
$phpmailer_smtpuser = 'xxx';
$phpmailer_smtppassword = 'yyy';
define('PHPMAILERPORT',587);
define("PHPMAILER_SECURE",'tls');

SERVER -> CLIENT: 250-mail.smtp2go.com Hello strontian [86.135.10.31]250-SIZE 52428800250-8BITMIME250-DSN250-PIPELINING250-AUTH CRAM-MD5 PLAIN LOGIN250-PRDR250 HELP
CLIENT -> SERVER: AUTH CRAM-MD5
SERVER -> CLIENT: 334 PDM3MzMuMTQ5OTk0NDUyMkBzbXRwY29ycC5jb20+
CLIENT -> SERVER: eHh4IDgwZTVjNjliNGUzODNjMjlkYWU4NmEyZTUyZjlmYjAw
SERVER -> CLIENT: 535 Incorrect authentication data
SMTP ERROR: Username command failed: 535 Incorrect authentication data
SMTP Error: Could not authenticate.

according to godaddy support they don’t allow external smtp services to connect to their hosting unless u upgrade to a dedicated server (grrr) and they only allow 500 max relays a day per email address.

So basically all of this has been for nothing. But thanks all for your help, much appreciated.

Karen

@MsKazza You might want to consider other services such as Amazon SES, Sendgrid and Mailgun that provide an API for sending emails. That means phplist sends the emails using http over port 80, which will not be blocked by Godaddy.

There are phplist plugins for those three services, see https://resources.phplist.com/plugins/start

@duncanc thank you so much for all your help. turns out smtp2go do supply an api, could your plugin be used with their api or is it specific to amazon? would it take much to modify if it doesn’t? and could i pay you to modify if needs be?

1 Like