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?


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.)

| improve this answer | |
  • 1
    With the above, this seems to have stopped me sending to external domains. When sending I now get 554 5.7.1 <user@domain.com>: 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 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.