Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?


locked by HopelessN00b 11 hours ago

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

1 Answer 1

up vote 11 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.)

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 –  Martin Smith 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. –  Martin Smith Apr 21 '11 at 12:37

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