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 [email protected]
mailhub=smtp.gmail.com:587 rewriteDomain=gmail.com hostname=gmail.com
FromLineOverride=YES [email protected]
AuthPass=oawprowcvxuwlsws UseTLS=Yes UseSTARTTLS=YES

added user to

sudo nano /etc/ssmtp/revaliases
root:[email protected]:smtp.gmail.com:587
www-data:[email protected]:smtp.gmail.com:587
pi:[email protected]: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 [email protected]

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" [email protected]
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?

asked Sep 28, 2020 at 10:40
4
  • raspberrypi.org/forums/… Commented Sep 28, 2020 at 13:40
  • Please state which version of OS you are using. Commented Sep 28, 2020 at 13:42
  • A Python implementation here Commented Sep 28, 2020 at 14:30
  • Not a question belonging to Raspberry Pi. Commented Sep 30, 2020 at 10:32

1 Answer 1

1

ssmtp is deprecated in Buster

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

NOTE configuration is different.

answered Sep 28, 2020 at 13:33
2
  • I think @Sama is using a older Raspbian version, hint /etc/log/mail.log Commented Sep 28, 2020 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 Commented Sep 28, 2020 at 20:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.