1

I have created a crontab for automatic backups of a SQL database and WWW data.

Now I would like to have the result of the crontab automatically sent to me by email. Result of the crontab are created succesfull

I have installed two packages

sudo apt-get install ssmtp
sudo apt-get install mailutils

and edited:

sudo nano /etc/ssmtp/ssmtp.conf

And in Gmail settings, created 2-steps-verification and added App-Pass

TLS_CA_FILE=/etc/ssl/certs/gmail.crt root=my_email@gmail.com
mailhub=smtp.gmail.com:587 rewriteDomain=gmail.com hostname=gmail.com
FromLineOverride=YES AuthUser=my_email@gmail.com
AuthPass=oawprowcvxuwlsws UseTLS=Yes UseSTARTTLS=YES

added user to

sudo nano /etc/ssmtp/revaliases


root:my_email@gmail.com:smtp.gmail.com:587
www-data:my_email@gmail.com:smtp.gmail.com:587
pi:my_email@gmail.com:smtp.gmail.com:587

Created certificate

sudo openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out /etc/ssl/certs/gmail.crt -keyout /etc/ssl/certs/gmail.key

testing ssmtp with

ssmtp -v my_email@gmail.com

result is:

[<-] 220 smtp.gmail.com ESMTP r8sm2599022edy.87 - gsmtp 
[->] EHLO gmail.com 
[<-] 250 SMTPUTF8 
[->] STARTTLS 
[<-] 220 2.0.0 Ready to start TLS 
[->] EHLO gmail.com 
[<-] ssmtp: (gmail.com)

Now try to send a Email from commandline

echo "Hello world email body" | mail -s "Test Subject" mysecondemail@gmail.com



mail: cannot send message: process exited with a non-zero status

In my logfile /etc/log/mail.log

Sep 25 23:19:40 raspberrypi sSMTP[11592]: Unable to set
TLS_CA_FILE="/etc/ssl/certs/gmail.crt" Sep 25 23:19:40 raspberrypi
sSMTP[11592]: Creating SSL connection to host Sep 25 23:19:41
raspberrypi sSMTP[11592]: SSL connection using
ECDHE_RSA_AES_256_GCM_SHA384 Sep 25 23:19:41 raspberrypi sSMTP[11592]:
(gmail.com)

What is missing or wrong?

4
1

ssmtp is deprecated in Buster

See https://raspberrypi.stackexchange.com/a/100704/8697 for alternative

NOTE configuration is different.

2
  • I think @Sama is using a older Raspbian version, hint /etc/log/mail.log – Mats Karlsson Sep 28 '20 at 13:42
  • Im using Distributor ID: Raspbian Description: Raspbian GNU/Linux 10 (buster) Release: 10 Codename: buster And I changed to msmtp, now its working. Thanks a lot – Sama Sep 28 '20 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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