Get postfix to forward root's mail

As ususal, check your logs.

In your case, the postfix daemon thinks the mail is not for it and sends it without using /etc/aliases

First check your /etc/hosts file : it should have your machine name corresponding to 127.0.1.1, like this:

127.0.1.1  linux1.mydomain.com  linux1

Check your /etc/mailname too, and it should be consistent.

Check your /etc/aliases to see if root (user) is sent to another user, and redo the newaliases command.

And it should work!


If mydestination is empty or does not contain $myhostname then the /etc/aliases will be ignored because postfix thinks the email is not a local delivery and will therefore not apply the local aliases. So, leave mydestination at the default (postconf -d mydestination or remove it from main.cf) and the logs should show the to=<...> as your aliased address.


In some circumstances, (i.e. where all mail gets relayed to an external system), it's easier to just set the MAILTO variable in root's crontab to a real email address. This should pretty much bypass traditional delivery to root and just make it go where you want.

# Root's crontab
[email protected]
0 0 * * * /usr/bin/somescript