Categories
Linux Mastering Development

Troubleshooting sSMTP: Authorization failed

My requirements are:

  • send an email from the terminal (for the sake of batch processing)
  • attach a pdf file to that email (the pdfs would be identical for all recipients, except for a watermark)
  • specify a reply-to address (myusername@gmail.com)

I’ve tried the "simplest answer to sending one-line messages via gmail is to use ssmtp", and several variants, and keep getting:

laptop sSMTP[19226]: Authorization failed (535 5.7.8
https://support.google.com/mail/?p=BadCredentials d13sm3920147qkj.27 –
gsmtp)

Google settings:

  • IMAP enabled
  • Allow less secure apps is ON

For each ssmtp.conf setup that I tried, I have done DisplayUnlockCaptcha just before:

$echo "Testing...1...2...3" | ssmtp myusername@gmail.com

Looking at the stated thread alone, there is no consensus as to how /etc/ssmtp/ssmtp.conf should be set up:

  • mailhub=smtp.gmail.com:587 vs 465
  • UseTLS=YES vs UseSTARTTLS=Yes (or both?)
  • hostname=localhost vs whatever was put there as the default (in my case, laptop)

Could someone make a suggestion to sort this out, and possibly paste in full a working conf file?

There is a claim in a thread from 2017, that:

You can not use external applications with your normal password, you
must go to https://security.google.com/settings/security/apppasswords

Is that the case? (I’m not able to do it)

What alternatives are there?

PS:

  • OS: Linux Mint 19 Tara
  • ssmtp was tested from a clean install preceded by upgrade/update
  • a couple of years ago, I was a able to send emails using the same OS (earlier version)
  • To make sure the value of AuthPass is correct, I used it to manually log into my google account.

Leave a Reply

Your email address will not be published. Required fields are marked *