Can't send emails through Google's SMTP server

Because emails sent through PHP Mail() function tends to end up in spam filters so often, we are trying to switch to SMTP.

I’ve done everything on this page: https://pkp.sfu.ca/wiki/index.php?title=Using_gmail_SMTP
But OJS is not sending out any emails. This is really frustrating, because with PHP Mail(), at least emails were sent out before they were filtered out by spam filters.

Where do I start to troubleshoot?

I’m having a similar problem with OJS 2.4.8-1. SMTP config in config.inc.php doesn’t work.
I telnet tested the external SMTP server and I finally found what the correct authentication string is (see this if you want to test your SMTP: Testing SMTP AUTH connections). So I guess there is a authentication issue.
I tried to modify config.inc.php to use the correct authentication string, but I was not able to solve the problem.
Let me know if you succeed.
Best regards

@Newtonite, have you checked your PHP error log?

@GinoSatta, I presume you’ve already asked this question more detail over here. Please only post the same question once; otherwise the forum gets cluttered.

Regards,
Alec Smecher
Public Knowledge Project Team

Error log contains the following:

I don’t understand where the “Could not authenticate” error is coming from. I’m using the same ID & password that I use to log into the Google Apps account.

[13-Nov-2016 00:10:51 America/Detroit] OJS SMTPMailer: Could not authenticate
[13-Nov-2016 00:16:26 America/Detroit] OJS SMTPMailer: Could not authenticate
[13-Nov-2016 00:22:32 America/Detroit] OJS SMTPMailer: Could not authenticate
[13-Nov-2016 00:26:48 America/Detroit] OJS SMTPMailer: Could not authenticate
[13-Nov-2016 00:34:54 America/Detroit] PHP Warning: mb_internal_encoding(): Unknown encoding "" in /home/eiblejournal/public_html/lib/pkp/classes/core/String.inc.php on line 71
[13-Nov-2016 00:35:01 America/Detroit] PHP Warning: mb_internal_encoding(): Unknown encoding "" in /home/eiblejournal/public_html/lib/pkp/classes/core/String.inc.php on line 71
[13-Nov-2016 00:35:07 America/Detroit] PHP Warning: mb_internal_encoding(): Unknown encoding "" in /home/eiblejournal/public_html/lib/pkp/classes/core/String.inc.php on line 71
[13-Nov-2016 00:35:11 America/Detroit] PHP Warning: mb_internal_encoding(): Unknown encoding "" in /home/eiblejournal/public_html/lib/pkp/classes/core/String.inc.php on line 71
[13-Nov-2016 00:37:10 America/Detroit] OJS SMTPMailer: Could not authenticate
[13-Nov-2016 00:41:34 America/Detroit] ojs2: 404 Not Found
[13-Nov-2016 00:41:43 America/Detroit] ojs2: 404 Not Found
[13-Nov-2016 00:41:58 America/Detroit] OJS SMTPMailer: Could not authenticate
[13-Nov-2016 00:42:26 America/Detroit] ojs2: 404 Not Found
[13-Nov-2016 01:18:57 America/Detroit] ojs2: 404 Not Found
[13-Nov-2016 01:47:15 America/Detroit] OJS SMTPMailer: Did not receive expected 220
[13-Nov-2016 01:53:11 America/Detroit] OJS SMTPMailer: Did not receive expected 220
[13-Nov-2016 01:56:26 America/Detroit] OJS SMTPMailer: Could not authenticate
[13-Nov-2016 01:58:04 America/Detroit] OJS SMTPMailer: Did not receive expected 220
[13-Nov-2016 01:59:57 America/Detroit] OJS SMTPMailer: Did not receive expected 220
[13-Nov-2016 02:03:19 America/Detroit] OJS SMTPMailer: Did not receive expected 220
[13-Nov-2016 02:04:07 America/Detroit] OJS SMTPMailer: Did not receive expected 220
[13-Nov-2016 02:06:10 America/Detroit] OJS SMTPMailer: Could not authenticate
[13-Nov-2016 02:15:40 America/Detroit] OJS SMTPMailer: Could not authenticate
[13-Nov-2016 02:23:15 America/Detroit] OJS SMTPMailer: Did not receive expected 220
[13-Nov-2016 08:45:54 America/Detroit] OJS SMTPMailer: Did not receive expected 220
[13-Nov-2016 09:01:11 America/Detroit] OJS SMTPMailer: Could not authenticate
[13-Nov-2016 09:11:32 America/Detroit] OJS SMTPMailer: Did not receive expected 220
[13-Nov-2016 10:43:47 America/Detroit] OJS SMTPMailer: Did not receive expected 220
[13-Nov-2016 10:44:55 America/Detroit] OJS SMTPMailer: Did not receive expected 220
[13-Nov-2016 11:30:08 America/Detroit] OJS SMTPMailer: Did not receive expected 220
[13-Nov-2016 15:46:58 America/Detroit] OJS SMTPMailer: Did not receive expected 220

I don’t think the warning mb_internal_encoding(): Unknown encoding "" is related to this issue, but you can probably fix it by checking your character set settings in config.inc.php.

There isn’t much to go on with the error OJS SMTPMailer: Could not authenticate; OJS SMTPMailer: Did not receive expected 220. Some steps to try:

  • Ensure PHP has SSL support (Linux, Windows)
  • Ensure your server is not blocked by a firewall to port 465 on smtp.gmail.com
  • Double check your password in config.inc.php - do you have it with quotes around it? without quotes around it?
  • Try changing your password to see if that makes a difference.

I tried the 3rd and 4th measures first, and neither worked. The password in config.inc.php doesn’t work with or without quotes around it.

Our site is being hosted by a 3rd party vendor. I’ll check the first two points with the service provider.

  • Ensure PHP has SSL support (Linux, Windows)
  • Ensure your server is not blocked by a firewall to port 465 on smtp.gmail.com
  • Double check your password in config.inc.php - do you have it with quotes around it? without quotes around it?
  • Try changing your password to see if that makes a difference.