I'm trying to redirect root mail on a CentOS 8 host to an external mail [email protected], 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" [email protected] works.

I tried forwarding via/root/.forward

[email protected]

echo test | mail -s "test" root, but now mails are sent to [email protected]

I tried forwarding via /etc/aliases

root: [email protected]

sudo newaliases && echo test | mail -s "test" root, but now mails are sent to [email protected]

Has anyone some ideas how I could achieve getting all mail to root forwarded to [email protected] ?

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 [email protected] address same as echo test | mail -s test [email protected] 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: [email protected]

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .