1

I wan to send an email from a linux command. I installed in ubuntu ssmtp, then I configured it in /etc/ssmtp/ssmtp.conf:

root=mymail@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=gmail.com
FromLineOverride=YES
AuthUser=mymail@gmail.com
AuthPass=xxxxxxxxx
UseTLS=YES
UseSTARTTLS=YES

then I tried to send the email like that:

ssmtp receiver_mail@gmail.com < msg.txt

But I got this error:

ssmtp: Authorization failed (535 5.7.8  https://support.google.com/mail/?p=BadCredentials t187sm393455wmt.25 - gsmtp)

then I tried with sendmail command:

 echo -n 'Subject: test\n\nTesting ssmtp' | sendmail -v receiver_mail@gmail.com

But I got the same error:

[<-] 220 smtp.gmail.com ESMTP a22sm418259wmd.20 - gsmtp
[->] EHLO omar-X550LC
[<-] 250 SMTPUTF8
[->] STARTTLS
[<-] 220 2.0.0 Ready to start TLS
[->] EHLO omar-X550LC
[<-] 250 SMTPUTF8
[->] AUTH LOGIN
[<-] 334 VXNlcm5hbWU6
[->] b21hci5rYWxsZWwzQGdtYWlsLmNvbQ==
[<-] 334 UGFzc3dvcmQ6
[<-] 535 5.7.8  https://support.google.com/mail/?p=BadCredentials a22sm418259wmd.20 - gsmtp
sendmail: Authorization failed (535 5.7.8  https://support.google.com/mail/?p=BadCredentials a22sm418259wmd.20 - gsmtp)

seems like that there's something wrong or missing in ssmtp config. Is there any suggestion to fix this issue?

Kallel Omar
  • 1,208
  • 2
  • 17
  • 51

1 Answers1

0

Did you try reading the support link it included in the error message? In addition to the possibility that you're supplying the wrong password, it gives a few other possibilities:

  • Use an App Password: If you use 2-Step Verification, try signing in with an App Password.
  • Allow less secure apps: If you don't use 2-Step Verification, you might need to allow less secure apps to access your account.
  • Make sure your mail app isn't set to check for new email too frequently. If your mail app checks for new messages more than once every 10 minutes, the app’s access to your account could be blocked.
Daniel McLaury
  • 4,047
  • 1
  • 15
  • 37