how to fix "send-mail: Authorization failed 534 5.7.14 "
I am trying to create e-mail alert on ssh root login so I had to install ssmtp and mail utility.
Then I configured ssmtp.conf file as follows :
# Config file for sSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
#root=postmaster
#Adding email id to receive system information
root = [email protected]
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#mailhub=mail
mailhub = smtp.gmail.com:587
[email protected]
AuthPass=plaintext password
UseTLS=YES
UseSTARTTLS=YES
# Where will the mail seem to come from?
rewriteDomain=gmail.com
# The full hostname
hostname = mailserver
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
as well as revaliases as follows:
# Format: local_account:outgoing_address:mailhub
# Example: root:[email protected]:mailhub.your.domain[:port]
root:[email protected]:smtp.gmail.com:25
and I am getting this error:
send-mail: Authorization failed (534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 ni5sm3908366pbc.83 - gsmtp)
Can't send mail: sendmail process failed with error code 1
but it didn't work. Please help me to sort out this
Solution 1:
It may take more than one step to fix this issue
Take the step mentioned earlier. Log into your google email account and then go to this link: https://www.google.com/settings/security/lesssecureapps and set "Access for less secure apps" to ON. Test to see if your issue is resolved. If it isn't resolved, as it wasn't for me, continue to Step #2.
Go to https://support.google.com/accounts/answer/6009563 (Titled: "Password incorrect error"). This page says "There are several reasons why you might see a “Password incorrect” error (aka 534-5.7.14) when signing in to Google using third-party apps. In some cases even if you type your password correctly." This page gives 4 suggestions of things to try.
For me, the first suggestion worked:
- Go to https://g.co/allowaccess from a different device you have previously used to access your Google account and follow the instructions.
- Try signing in again from the blocked app.
There were three more suggestions on the page given in step #2 but I didn't try them because after going to the redacted link and following the instructions, everything began to work as it should.
Solution 2:
This worked for me.
1) Login to your gmail account.
2) Go to https://www.google.com/settings/security/lesssecureapps and Turn On this feature.
3) Go to https://accounts.google.com/DisplayUnlockCaptcha and click Continue.
Then you can authenticate your Additional Email Address from your Gmail Account.
Edit: In my case it helped to write smtp.gmail.com instead of smtp.gmail.com:587.
Solution 3:
To fix this issue, you need to:
1) Login to your Gmail account using the web browser.
2) Click on this link to enable applications to access your account: https://accounts.google.com/b/0/DisplayUnlockCaptcha
3) Click on Continue button to complete the step.
4) Now try again to send the email from your PHP script. It should work.