GMail SMTP App Password Not Working

Describe the issue or problem
I know Gmail recently did away with less secure apps access, and our email stopped working from OJS on March 24th. I verified our less secure app access no longer works by using Thunderbird.

But they do still support app passwords. I enabled MFA, then created an app password. This allowed me to use SMTP using Thunderbird withbot 587/STARTTLS, and 465 with TLS/SSL.

However it is still not working from OJS. I have tried SSL/465, and TLS/587 in my config file.

Any ideas I can try? Is there a way to specify STARTTLS?

What application are you using?
OJS 3.3.0.15

Additional information

A few additional tests:

  1. I set up an app password on a personal Gmail account, and this, too fails. So, not related to the specific journal gmail account.
  2. I tested the journal’s app password using a Wordpress site hosted on the same server as the journal, and no issues with both SSL/465 and STARTTLS/587, so not hosting related.

I figured it out but it was a bit of a shot in the dark as this does not appear documented in OJS documentation.

Google app passwords are 16 characters long, with spaces in between each 4 characters. Example: abcd efgh ijkl mnop

So, my config file looked like:
smtp_password = abcd efgh ijkl mnop

As a test I put quotes around the password, and thus, it worked. So:
smtp_password = “abcd efgh ijkl mnop”

I did not need quotes in my previous “less secure app” complex password, which was complex but did not have spaces. It seems OJS needs quotes when there are spaces in a password.

Hello

With this configuration, does your server continue sending emails? We have the same problem.

Indeed yes it began sending emails again, using quotes around the app password. You just need to make sure you are using an app password generated for the account, and not the old “less secure apps” setting using the account’s actual password.