Gmail smtp SASL authentication

Trong Lam Phan picture Trong Lam Phan · Jan 14, 2018 · Viewed 9.8k times · Source

I'm using postfix to send email via gmail with an application's password (two step-validation activated).

Each time I test sending mail using sendmail command, I get this error:

Action: delayed
Status: 4.7.14
Diagnostic-Code: X-Postfix; delivery temporarily suspended: SASL authentication
failed; server smtp.gmail.com said: 534-5.7.14
<https://accounts.google.com/signin/continue?...> Please log in via your web browser and?534-5.7.14 then try again.?534-5.7.14

This is my postfix configuration:

main.cf

myorigin = /etc/mailname
mydestination = mydomain.com, localhost.fr, localhost
relayhost = [smtp.gmail.com]:587

smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_tls_security_level = encrypt
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

/etc/postfix/sasl/sasl_passwd:

[smtp.gmail.com]:587 [email protected]:application_password

And this is how I used sendmail:

sendmail -v ...
From: [email protected]
Subject: Test
This is a test mail
.

Any ideas ? Thanks !

Answer

jcaruso picture jcaruso · Feb 24, 2020

For anyone finding this who has run into the same scenario:

  1. Using an app specific password
  2. 2FA enabled on your account
  3. Seeing 'delivery temporarily suspended: SASL authentication failed; server smtp.gmail.com[173.194.68.109] said: 534-5.7.9 Please log in with your web browser and then try again' in your log

You may need to visit https://accounts.google.com/DisplayUnlockCaptcha to 'bypass' the captcha, which will enable the account access and get everything working.