LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sending emails with postfix and gmail - SASL authentication failed (https://www.linuxquestions.org/questions/linux-newbie-8/sending-emails-with-postfix-and-gmail-sasl-authentication-failed-4175605840/)

NotionCommotion 05-13-2017 10:07 AM

Sending emails with postfix and gmail - SASL authentication failed
 
Trying to send emails with sendmail on Centos6 using gmail as a relay, however, SASL authentication fails.

Package cyrus-sasl-plain-2.1.23-15.el6_6.2.x86_64 already installed and latest version.

Edited /etc/postfix/sasl_passwd as smtp.gmail.com GmailUsername:GmailPassword, and hashed.

Added the following to /etc/postfix/main.cf:
Code:

relayhost = smtp.gmail.com:587
#relayhost = [smtp.gmail.com]:587

smtp_tls_security_level = secure
smtp_tls_mandatory_protocols = TLSv1
smtp_tls_mandatory_ciphers = high
smtp_tls_secure_cert_match = nexthop
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
#smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
#smtp_sasl_mechanism_filter = login
#smtp_use_tls = yes

The response I get is:
Code:

May 13 07:31:33 devserver postfix/error[15419]: 42995200199: to=<toemail@gmail.com>, relay=none, delay=0.13, delays=0.09/0/0/0.04, dsn=4.7.14,
status=deferred (delivery temporarily suspended: SASL authentication failed;
server smtp.gmail.com[108.177.98.108] said:
534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=xxx?534-5.7.14 xxx-xxx?534-5.7.14 xxx-xxx-xxx?534-5.7.14 ShcA709Mb-xxx?534-5.7.14 xxx>
Please log in via your web browser and?534-5.7.14 then try again.?534-5.7.14  Learn more at?534 5.7.14  https://support.google.com/mail/answer/78754 xxx.77 - gsmtp)

As a last resort, I tried reducing gmails security per https://support.google.com/accounts/answer/6010255, but didn't help.

EDIT. I just changed /etc/postfix/main.cf form relayhost = smtp.gmail.com:587 to relayhost = [smtp.gmail.com]:587, and now I get the following. Looks like a good sign I hope.

Code:

May 13 08:57:11 devserver postfix/pickup[22206]: 40FA720012C: uid=500 from=<Michael>
May 13 08:57:11 devserver postfix/cleanup[22220]: 40FA720012C: message-id=<20170513155711.40FA720012C@example.com>
May 13 08:57:11 devserver postfix/qmgr[22207]: 40FA720012C: from=<Michael@example.com>, size=286, nrcpt=1 (queue active)
May 13 08:57:11 devserver postfix/smtp[22222]: 40FA720012C: to=<sendto@gmail.com>, relay=smtp.gmail.com[74.125.28.109]:587, delay=0.33, delays=0.12/0/0.18/0.03, dsn=5.5.1, status=bounced (host smtp.gmail.com[74.125.28.109] said: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1  https://support.google.com/mail/?p=WantAuthError 20sm13518391pfq.42 - gsmtp (in reply to MAIL FROM command))
May 13 08:57:11 devserver postfix/cleanup[22220]: CA431200138: message-id=<20170513155711.CA431200138@example.com>
May 13 08:57:11 devserver postfix/bounce[22225]: 40FA720012C: sender non-delivery notification: CA431200138
May 13 08:57:11 devserver postfix/qmgr[22207]: CA431200138: from=<>, size=2308, nrcpt=1 (queue active)
May 13 08:57:11 devserver postfix/cleanup[22220]: D393E20010E: message-id=<20170513155711.D393E20010E@example.com>
May 13 08:57:11 devserver postfix/bounce[22226]: 40FA720012C: sender delivery status notification: D393E20010E
May 13 08:57:11 devserver postfix/qmgr[22207]: 40FA720012C: removed
May 13 08:57:11 devserver postfix/qmgr[22207]: D393E20010E: from=<>, size=2107, nrcpt=1 (queue active)
May 13 08:57:11 devserver postfix/local[22227]: CA431200138: to=<Michael@example.com>, relay=local, delay=0.11, delays=0.04/0.04/0/0.04, dsn=5.1.1, status=bounced (unknown user: "michael")
May 13 08:57:11 devserver postfix/local[22228]: D393E20010E: to=<Michael@example.com>, relay=local, delay=0.07, delays=0.04/0/0/0.04, dsn=5.1.1, status=bounced (unknown user: "michael")
May 13 08:57:11 devserver postfix/qmgr[22207]: CA431200138: removed
May 13 08:57:11 devserver postfix/qmgr[22207]: D393E20010E: removed

What can I do?

Thank you

EDIT 2. Don't know what changed, but went back to relayhost = smtp.gmail.com:587, and now can send emails :)

kentyler 05-26-2017 03:13 PM

From the link that gmail sends in the error:

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


All times are GMT -5. The time now is 12:44 PM.