Configure unattended upgrades notification e-mail's from address

I've recently built a server using 14.04.1 LTS, I wanted a very quick and simple way for it to let me know if, for example, it needed a system restart after installing upgrades. I decided e-mail was the best option.

I've installed, configured and tested ssmtp to use one of my usual e-mail services.

Also, I've configured unattended-upgrade to e-mail me after any upgrades, at least initially.

Can I get the unattended-upgrade e-mail to come from a specific address? I know I can do that using just mail or ssmtp directly but if I don't specify a "from" address then it defaults to my mail service's default account and I want it to be clear it came from this particular machine. Where can I specify a "from" address for the mail command that unattended-upgrade uses?


Found in /usr/bin/unattended-upgrade:

from_email = apt_pkg.config.find("Unattended-Upgrade::Sender", "root")

So by default it will use "root" as a sender, which (at least in my case) can lead to a rejection of the email due to missing or wrong from field.

You can change the sender in /etc/apt/apt.conf.d/50unattended-upgrades, for example:

Unattended-Upgrade::Sender "Unattended-upgrades Hostname <[email protected]>";

Just specify an alias in your mail.rc file:

alias root root<[email protected]>

@Fabby - Thank you for your suggestion, I couldn't find a mail.rc file anywhere but you pointed me in the right direction. (I tried to vote up your answer but I'm apparently too much of a noob!)

Just to check, I did a sendmail -V which confirmed that I was using sSMTP.

Re-reading the docs on sSMTP pointed me at setting an alias as suggested but in either /etc/aliases or /etc/ssmtp/revaliases.

/etc/aliases already contained an entry for root - and changing it seems to have no visible effect on sent e-mail headers or contents. (Is it for incoming mail I'm thinking...?)

However, adding:

root:[email protected]:MyMailHub.com

to /etc/ssmtp/revaliases did result in mail generating a message with:

From: root <[email protected]> 

which isn't exactly what I wanted but is good enough.

Ironically, when I logged into the server to try this, it informed me that a system restart was required but I have no e-mail to alert me to that so I must still not have that set up correctly... back to square one!