Score:0

smtp send email on unattended upgrades in Ubuntu

vn flag

Hello I have setup unattended upgrades on my Ubuntu 20.04 server with msmtp and sendmail. And want to send the result of Unattended-Upgrade to my email. But the email is not sending by Unattended-Upgrade!

I have add my email Adress to the Unattended-Upgrade settings:

Unattended-Upgrade::Mail "me@yahoo.de";

My /etc/mail.rc looks like:

set sendmail="/usr/bin/msmtp -t"

My msmtp config (/etc/msmtprc) looks like:

defaults
port 587
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

account me@yahoo.de
host smtp.mail.yahoo.com
from me@yahoo.de
auth on
logfile /var/log/msmtp
user me@yahoo.de
password abc
account default: me@yahoo.de
aliases /etc/aliases

With the permissions:

ls -l /etc/msmtprc    
-rw-r----- 1 root msmtp 2741 Dec 15 12:23 /etc/msmtprc

The same config I have in my user Dir (/home/me/.msmtprc):

ls -l /home/me/.msmtprc                                       
-rw------- 1 me msmtp 2725 Dec 15 09:51 /home/me/.msmtprc

Now I'm able to successfully send emails with:

echo "content" | mail -s "test email" me@yahoo.de

the log of the command above in /var/log/msmtp is:

Dec 15 13:04:31 host=smtp.mail.yahoo.com tls=on auth=on user=me@yahoo.de from=me@yahoo.de recipients=me@yahoo.de mailsize=153 smtpstatus=250 smtpmsg='250 OK , completed' exitcode=EX_OK

But when I run unattended-upgrade manually sudo /usr/bin/unattended-upgrade -d I get:

bla bla bla
bla bla bla
bla bla bla
Sending mail to me@yahoo.de
sendmail: the server sent an empty reply
sendmail: could not send mail (account default from /etc/msmtprc)
mail returned: 76

The log of the cammand above is:

Dec 15 13:23:03 host=smtp.mail.yahoo.com tls=on auth=on user=me@yahoo.de from=me@yahoo.de recipients=me@yahoo.de errormsg='the server sent an empty reply' exitcode=EX_PROTOCOL
sol2070 avatar
bo flag
I was having a very similar issue. [This](https://askubuntu.com/a/1233655) worked for me.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.