When setting up Postfix on Ubuntu/Debian as “Internet Site with smarthost” to use an external smtp relay, automatic e-mails intended for “root” (such as cron job error reports) get sent out to the smarthost with a To: address of email@example.com. This can cause a problem as the smarthost doesn’t know where to deliver these messages to, since myhost.mydomain.com has no MX record.
The fix for this is (go figure) in the Postfix README:
Delivering some but not all accounts locally
A drawback of sending mail as “firstname.lastname@example.org” (instead of “email@example.com”) is that mail for “root” and other system accounts is also sent to the central mailhost. In order to deliver such accounts locally, you can set up virtual aliases as follows:1 /etc/postfix/main.cf: 2 virtual_alias_maps = hash:/etc/postfix/virtual 3 4 /etc/postfix/virtual: 5 root root@localhost 6 . . .
- Line 5: As described in the virtual(5) manual page, the bare name “root” matches “root@site” when “site” is equal to $myorigin, when “site” is listed in $mydestination, or when it matches $inet_interfaces or $proxy_interfaces.
Execute the command “postmap /etc/postfix/virtual” after editing the file.
Oddly, just adding the line
to /etc/aliases doesn’t work. You really need to do the steps outlined in the manual.