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?
-
raspberrypi.org/forums/…Dougie– Dougie2020年09月28日 13:40:25 +00:00Commented Sep 28, 2020 at 13:40
-
Please state which version of OS you are using.Mats Karlsson– Mats Karlsson2020年09月28日 13:42:33 +00:00Commented Sep 28, 2020 at 13:42
-
A Python implementation hereSeamus– Seamus2020年09月28日 14:30:43 +00:00Commented Sep 28, 2020 at 14:30
-
Not a question belonging to Raspberry Pi.Ingo– Ingo2020年09月30日 10:32:27 +00:00Commented Sep 30, 2020 at 10:32
1 Answer 1
ssmtp is deprecated in Buster
See https://raspberrypi.stackexchange.com/a/100704/8697 for alternative
NOTE configuration is different.
-
I think @Sama is using a older Raspbian version, hint
/etc/log/mail.log
Mats Karlsson– Mats Karlsson2020年09月28日 13:42:10 +00:00Commented Sep 28, 2020 at 13:42 -
Im using
Distributor ID: Raspbian Description: Raspbian GNU/Linux 10 (buster) Release: 10 Codename: buster
And I changed tomsmtp
, now its working. Thanks a lotSama– Sama2020年09月28日 20:42:48 +00:00Commented Sep 28, 2020 at 20:42