6

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 admin@mydomain.com:application_password

And this is how I used sendmail:

sendmail -v ...
From: admin@mydomain.com
Subject: Test
This is a test mail
.

Any ideas ? Thanks !

Trong Lam Phan
  • 2,292
  • 3
  • 24
  • 51
  • I am also facing authentication issue in posix configuration using smtp.gmail.com. May 7 15:59:32 apurb-ThinkPad-E470 postfix/smtp[10589]: 4CC0728214FB: to=, relay=smtp.gmail.com[64.233.186.109]:587, delay=896, delays=894/0.07/1.7/0, dsn=4.7.8, status=deferred (SASL authentication failed; server smtp.gmail.com[64.233.186.109] said: 535-5.7.8 Username and Password not accepted. Learn more at?535 5.7.8 https://support.google.com/mail/?p=BadCredentials t7sm9274499qte.74 - gsmtp) Any idea how to resolve this issue? – intechops6 May 07 '19 at 20:09
  • Any chance you found a solution to this? I am getting the same error and I am using my application specific password and I have 2FA enabled on my main account. – jcaruso Feb 23 '20 at 23:12

3 Answers3

6

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.

jcaruso
  • 950
  • 11
  • 19
3

Allow less secure apps: If you don't use 2-Step Verification, you might need to allow less secure apps to access your account.

enter image description here

Pipo
  • 4,653
  • 38
  • 47
  • What if you are using 2FA? – qodeninja Aug 24 '18 at 05:29
  • 1
    @qodeninja in this case you need to create an app password that can be used with postfix. – dseifert Sep 28 '18 at 07:46
  • 1
    This setting is no longer available in google. It is now required to enable 2FA and then create a specific app password, see @jcaruso answer or https://support.google.com/accounts/answer/185833 – Redoman Oct 19 '22 at 16:09
0

In my case i was connecting from Synology NAS Mail Server with SMTP Relay. The solution is to:

  1. visit your Google account
  2. click Security
  3. search and click "App Passwords" (type "other app")
  4. create an app password and copy it to clipboard
  5. login form your app using your full email as username and the password from the clipboard as password

For Synology this should be:

  • enable relay: true
  • server: smtp.gmail.com
  • port: 587
  • always use TLS: true
  • authentication neccessary: true
  • account: [your-full-email-address]
  • password: [the-app-password-you-just-created]
Stefan
  • 12,108
  • 5
  • 47
  • 66