Try /etc/apt/apt.conf.d/50unattended-upgrades
// Send email to this address for problems or packages upgrades
// If empty or unset then no email is sent, make sure that you
// have a working mail setup on your system. A package that provides
// 'mailx' must be installed. E.g. "user@example.com"
Unattended-Upgrade::Mail "user@example.com";
// Set this value to "true" to get emails only on errors. Default
// is to always send a mail if Unattended-Upgrade::Mail is set
Unattended-Upgrade::MailOnlyOnError "false";
That's actually the easy part. Next, we must set up a lightweight postal system to get the e-mail off the server and over to you.
Here's one way to do that:
sudo apt install msmtp msmtp-mta bsd-mailx
Config file: /root/.msmtprc
account your_label_here
host smtp.example.com
port 465
from root@your_machine.your_domain
user user@example.com (your email)
password your_smtp_password
auth on
tls on
tls_starttls off
tls_certcheck off
logfile /root/.msmtp.log
account default : your_label_here
Test command:
echo "This is the email body" > /tmp/body.txt && sudo mailx -s "This is the subject" user@example.com < /tmp/body.txt; rm /tmp/body.txt