postfix accept remote but don't relay

moztech asked:

I’m trying to configure a basic postfix server to allow receipt of email from anywhere to local addresses but not be an open relay.

Current config, seemingly relevant rules:

mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks =
relay_domains = $mydestination

If I change mynetworks back to it doesn’t receive external mail.
Leaving relay_domains blank seems to make no difference and keeps this as an open relay.

What am I missing?

My answer:

First, relay_domains is not necessary unless you’re making this system a backup MX (you aren’t) and therefore should be removed.

Second, mynetworks = makes you an open relay. It also should be removed and replaced with something more sensible, such as mynetworks =

Finally, mydestination should specify the domains for which you want to receive email. You don’t seem to have listed any domains here. Add in your domain names.

Once you fix all three of these issues, you should have a functional mail server which isn’t open relaying.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.