0

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?

0

I found the solution that helped me achieve what I want and it's described here. Basically I had to change the mydestination in /etc/postfix/main.cf to be empty to prevent local delivery.

On top of that I changed my maps to exclude the second @foo.com line and replaced the root with the postfix username.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.