I have an Ubuntu 18.04 VM that has postfix installed and works fine e-mailing notifications when there is an unattended upgrade or when a reboot is required. E-mails are sent to my personal e-mail account using gmail as relay host:
relayhost = [smtp.gmail.com]:587
The problem is when there is an e-mail for the root user, in this case, I want those e-mails also be sent to my personal address. After doing some research I found that there are two ways to do that.
In the first option I created a file called /root/.forward and added my personal email address, rebooted the VM but the root e-mails were still being forwarded to root@domain.com.
The second option was to edit the /etc/aliases file and add my external address:
postmaster: root
root: personal@externadomain.com
then run:
sudo newaliases
and re-started postfix:
service postfix restart
but again, when testing:
echo test | mail -s "test message" root
the e-mail was again sent to root@domain.com and not my personal address.
What seems to be an easy task doesn't seem to be working for me.
Any idea on what do I am missing?
Call logs are as follows:
Sep 6 00:38:24 hol-01-bwt postfix/pickup[2453]: 77645120105: uid=0 from=<root@ServerDomain.com>
Sep 6 00:38:24 hol-01-bwt postfix/cleanup[17908]: 77645120105: message-id=<20200906043824.77645120105@ServerDomain.com>
Sep 6 00:38:24 hol-01-bwt postfix/qmgr[4710]: 77645120105: from=<root@ServerDomain.com>, size=455, nrcpt=1 (queue active)
Sep 6 00:38:26 hol-01-bwt postfix/smtp[17914]: 77645120105: to=<Personal.Address@PersonalDomain.com>, relay=smtp.gmail.com[74.125.26.108]:587, delay=1.8, delays=0.05/0.08/0.68/1, dsn=2.0.0, status=sent (250 2.0.0 OK 1599367106 i3sm1850454vke.5 - gsmtp)
I have modified the root domain and my personal domain. According to the logs all should be fine as the email is sent to my personal e-mail.
However, I never received any e-mail form the test and my gmail mailbox says that the message wasn't delivered to root@serverDomain because the domain couldn't be found (of course). It was supposed to be sent to Personal.Address@PersonalDomain.com