0

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

olg32
  • 101
  • 1
  • What's in the mail logs for these messages? – Michael Hampton Sep 07 '20 at 03:29
  • Hi, please see the logs I added in the problem description. – olg32 Sep 07 '20 at 22:22
  • That message was delivered to Gmail, not to your local mail spool. What happened to it after that? Your post has a vague description, but you need to be specific. – Michael Hampton Sep 08 '20 at 00:44
  • Michael, yes, the relay host is my Gmail account, but the destination should be Personal.Account@Personal.Domain.com, not gmail.com. Anyhow, I found the problem so I'll Answer my question. Thanks. – olg32 Sep 09 '20 at 17:53

1 Answers1

0

Problem was solved by deleting the mydestination parameter on /etc/postfix/main.cf

This is because the /etc/aliases was being ignored as postfix thinks the email is not a local delivery so it will not apply the local aliases.

after removing the parameter, root mail was forwarded to my e-mail address.

olg32
  • 101
  • 1