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;


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


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 ?

1 Answer 1


Hi I was struggling with this too, followed multitude of tutorials and ended up with working solution, but hard to say which part of which tutorial exactly was it.

Anyways, to get echo test | mail -s test root automatically sent to myaddress@gmail.com address same as echo test | mail -s test myaddress@gmail.com does on my Raspberry Pi Zero:

I edited /etc/postfix/main.cf like so:

myhostname = zero.lan

smtpd_banner = $myhostname ESMTP $mail_name (Raspbian)
biff = no

append_dot_mydomain = yes

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks =
inet_interfaces = loopback-only
recipient_delimiter = +
relay_domains =
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_use_tls = yes
compatibility_level = 2

then edited /etc/aliases like so:

postmaster: root
root: localuser
localuser: myaddress@gmail.com

and ran sudo newaliases and sudo systemctl reload postfix and that did the trick for me.

Your Answer

