I have a domain foo.com
pointing to my server and have MX entries redirecting to an external (!) mail provider where I can send and receive mails via mail@foo.com
. Since I am running some applications on my server that should send mail notifications I have installed postfix with the following changes to /etc/postfix/main.cf
:
mydestination = $myhostname, localhost.$mydomain, $mydomain
inet_interfaces = loopback-only
smtp_generic_maps = hash:/etc/postfix/generic
And the respective /etc/postfix/generic
looks like this:
root@foo.com no-reply@foo.com
@foo.com no-reply@foo.com
Unfortunately it turns out that sending mails locally (either via mail
or the applications connecting to the localhost) to my mail@foo.com
will of course conflict with the local postfix installation that should not receive the mail and the mail should rather be forwarded to my externally hosted mail server from the provider.
How can I configure the server such that locally sent mails to mail@foo.com
will in fact reach the external server?