Error sending password change token v3.6.5

Sending any test emails fail with

Error sending email to name@mydomain.co.nz SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

trying to update an admin by checking new password email and phpList presents Error sending password change token and no email is received.

My first glance is that I must have my SMTP username or password incorrect, but I’ve troubleshot that by literally copying from config.php and pasting into a gmail login to make sure they provide access. This account has IMAP enabled and ‘Allow access for less secure apps’ is ON.

Apologies for whatever newb mistake I’m making. I’ve done a manual install of phpList v3.6.5 on our own Ubuntu 18.04 LTS server, but aim to serve out lists via smtp.gmail.com. Install and configuration seemed to go without a hitch, Configure > Checklist are all green. The database functions ok and dashboard operates as expected. I’ve updated configure.php with

define('PHPMAILERHOST','smtp.gmail.com');
$phpmailer_smtpuser = 'listserv@mygsuitedomainname.co.nz';
$phpmailer_smtppassword = 'password';
define("PHPMAILERPORT",'587');
define("PHPMAILER_SECURE",'tls');

Although unnecessary here, the server can send php mail fine (e.g. using echo “Hiya Brian” | mail -s “Email test” myname@myotherdomain.ac.nz so I thought all the php mail handling stuff is fine.

Ports UFW 587, 25, and 465 (both ip4 and 6) Allow OUT from Anywhere.

What didn’t I think of here?!

@brian.paavo Is it only the password reset email that is failing, or does sending a test campaign fail as well?

You can enable smtp debug in config.php then send a test email when composing a campaign.

define('PHPMAILER_SMTP_DEBUG', 2);

Test campaign fails as well.

Ahhhaa! As almost always the case, found a problem in config.php. I see that even though I had added the smtp code into config.php later, I hadn’t seen that there was an earlier default define('PHPMAILERHOST",‘localhost’); that I hadn’t commented out so PHP processed it first.

I can only hope that this post helps someone else later on.

Thanks for taking the time to respond and encourage my relook.