53

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 = rootuser@gmail.com
# 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

AuthUser=dmymail@gmail.com
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:your_login@your.domain:mailhub.your.domain[:port]

root:rootuser@gmail.com: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

  • possible duplicate of sSMTP Unable to send message using external mail server SMTP – mailq Oct 10 '14 at 17:50
  • Got this error last night after it has been working for several months. – ceving Sep 30 '15 at 18:15
  • After doing all the suggested steps it still failed UNTIL I simply changed my gmail.com password even though I was using correct password ... maybe its a new Google security precaution – Scott Stensland Aug 29 '16 at 21:48
  • @ceving what was the remedy? How did you fix it? – 3kstc Dec 7 '17 at 3:03
77

It may take more than one step to fix this issue

  1. 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.

  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.

  • 9
    Option 1. worked for me – Patrick Forget Sep 30 '15 at 18:40
  • FYI, you can enable this for your entire company if using google apps for business, in Security settings. – Travis Reeder Apr 9 '16 at 20:44
  • 2
    +1, Option 1 followed by g.co/allowaccess worked perfectly. – greg_data Jan 3 '17 at 12:06
  • Took me a few minutes but I found how to enable for entire organization in Admin Console under Security > Basic Settings > Less Secure Apps > Enforce Access ... which for the sake of added confusion shows "Advanced security settings" in the title (though I couldn't find a link to that page via the Advanced security settings...). Confused? So am I! – isapir Jan 24 '17 at 17:30
10

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.

4

I had this same issue, be sure to take a look at your gmail account security settings and enable "Access for less secure apps" from www.google.com/settings/security.

it will then magically start to work.

  • This is helpful and i fixed the same problem after applying change to my gmail account security settings by allowing "Access for less secure apps" from www.google.com/settings/security. The related helpful link can be found here – user261995 Jan 1 '15 at 13:42
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.

  • This might not really be an answer for a linux core install. And I'm not entirely sure this will persist after daemon restarts. You're better off following the insecure app instructions. – Reaces Jan 9 '15 at 10:49
  • It worked for me. Linux core install. I logged from another computer. – Michal Sokolowski May 28 '15 at 13:53
1

This happens because Google recently implemented a policy change, which in their own words, is one in a series of changes to strengthen email authentication, and end any practices by Google products which break authentication.

There are many options being suggested such as to change the ports for the smtp server, to enable "allow less secure apps" option in Security settings tab etc.

One solution which works, is to enable Gmail's Two step authentication for the AuthUser, generate an app specific password, and use this password as the Gmail password when setting up "Send mail as" option. Once you create an app only password and use it in /etc/ssmtp/ssmtp.conf, at AuthPass=, you can disable two step verification without revoking Two step verification.

0

Have you followed the provided link and read the instructions? This is how to fix it.

I'll bet you entered the wrong username or password.

If they are really correct, verify that you use the same port. Above you specified 587 whereas below you specified 25.

Then it is probably not OK to specify UseTLS and UseSTARTTLS. On port 587 use UseTLS, with port 25 use UseSTARTTLS.

At the end your hostname is likeley not "mailserver". Use a FQDN.

  • @mmailq,As per your solution I changed the port no to 587 on both the conf file and I am sure that the username and password are correct. – Connect Oct 10 '14 at 17:43
  • @@mmailq,what should be the FQDN? my server hostname is mailserver. – Connect Oct 10 '14 at 17:45
  • @@mmailq, no it is not working the same error is coming. – Connect Oct 10 '14 at 17:52
0

I fixed it by creating a new GMail account, for mail sending only, activated the two-phases-auth, and generated an app password.

It works like a charm!

protected by Community May 26 '16 at 13:52

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.