Gmail smtp SASL authentication

13,609

Solution 1

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.

Solution 2

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

Share:
13,609
Trong Lam Phan
Author by

Trong Lam Phan

Updated on June 04, 2022

Comments

  • Trong Lam Phan
    Trong Lam Phan almost 2 years

    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 !