I'm trying to redirect root mail on a CentOS 8 host to an external mail external@externaldomain.tld, so I get an email notifications when cronjobs fail.
The receiving mail server is on Uberspace.de. I set up a domain I own in postfix on the sending CentOS 8 host;
/etc/postfix/main.cf
mydomain = mydomain.org
myorigin = $mydomain
as otherwise (like when the FROM domain has no MX record) all mail sent to the recipient mail server on uberspace would be rejected with
said: 550 No MX for your FROM address (in reply to MAIL FROM command)
Testing the mail with echo test | mail -s "test" external@externaldomain.tld
works.
I tried forwarding via/root/.forward
externaluser@externalmail.com
echo test | mail -s "test" root
, but now mails are sent to root@mydomain.org
I tried forwarding via /etc/aliases
root: externaluser@externalmail.com
sudo newaliases && echo test | mail -s "test" root
, but now mails are sent to root@mydomain.org
Has anyone some ideas how I could achieve getting all mail to root forwarded to externaluser@externalmail.com ?