Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I configure the Postfix mail submission agent to only allow emails to be sent out from a user on localhost , but allow the Postfix mail transfer agent to receive mail from anywhere?

share|improve this question
up vote 14 down vote accepted

The simplest way is to make sure you have only localhost defined in mynetworks:

mynetworks =, [::1]/128

By default smtpd_recipient_restrictions is set as:

smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination

This will allow hosts defined in mynetworks (localhost, as above) to send anywhere, while everything else is rejected unless it's destined for your box or otherwise explicitly allowed (relay domains, virtual domains, or whatever other configurations you're allowing.)

share|improve this answer
With the above, this seems to have stopped me sending to external domains. When sending I now get 554 5.7.1 <>: Relay access denied – linus1412 Apr 21 '11 at 12:11
My bad! Doing this logged in to the box works fine. It was failing when I was trying to do this by tunnelling via ssh to the mail server. I thought this would have been equivalent to being on the box. – linus1412 Apr 21 '11 at 12:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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