I'm trying to redirect root mail on a CentOS 8 host to an external mail email@example.com, 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;
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" firstname.lastname@example.org works.
I tried forwarding via/root/.forward
echo test | mail -s "test" root, but now mails are sent to email@example.com
I tried forwarding via /etc/aliases
sudo newaliases && echo test | mail -s "test" root, but now mails are sent to firstname.lastname@example.org
Has anyone some ideas how I could achieve getting all mail to root forwarded to email@example.com ?