Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

Possible Duplicate:
How can I set up Postfix so that all email sent on my dev box gets routed to the developer email group?

I have a staging web server, and I have previously prevented any and all mail being sent out from it (I don't want my clients getting test messages from it). I've now set up postfix, but I want to restrict it so that the server only ever sends emails to recipients at one domain name. I've tried:

relay_domains =  
smtpd_recipient_restrictions = reject_unauth_domain

.. among other variations. I've just switched it to simply this to see if that made any difference:

smtpd_recipient_restrictions = reject

But it's still sending out mail. I think all I'm doing is changing the relay settings, and I need to be changing something else, but can't make head or tail of the documentation.

I'm running postfix reload after each change, and postfix restart. This is on Ubuntu server.

share|improve this question

marked as duplicate by Chris S, Ward, sysadmin1138 Oct 14 '11 at 21:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Please do not double post. If you wanted to draw attention to your older question you could have edited new detail in or put up a bounty. – Chris S Oct 14 '11 at 19:42

I have a cheesy idea: set the smart host valid to an invalid ip address. Then emails that are local to the box will get delivered, but everything else will queue up waiting for delivery to that non existent host. Then just delete those every few days.

Another idea would be to use the transports file to redirect email for your customer domains to a non existent server. Or to a test server that is setup to accept email for all/multiple domains (such as your customer's domains).

share|improve this answer
Thanks Walter. Unfortunately, this blocked the emails that I wanted to be sent (which aren't hosted on the same box). – Dave Child Feb 11 '11 at 12:06

This is the same idea as Walter provided, but more of an example with which you should be able to figure out what to do:

testbox:/etc/postfix# grep transport
transport_maps = hash:/etc/postfix/transport
testbox:/etc/postfix# cat /etc/postfix/transport     relay:[]
* local:
testbox:/etc/postfix# grep luser_relay
luser_relay = aLocalUser
testbox:/etc/postfix# postmap transport

Oh-- "aLocalUser" is of course a local user on your box that will receive all of the emails that aren't actually being delivered externally.

share|improve this answer
Thanks Unixguy. Sadly, although I should be able to figure out what to do from this ... it seems I can't. Is the line configured to deliver email to our domain via the relay, and then anything else (*) set to just sit locally? This sounds like it will block all email delivered to other domains and deliver it to a local user - can I then have that mail delivered externally (to a developer group address, for example)? – Dave Child Feb 11 '11 at 12:09
up vote 0 down vote accepted

I asked this question a second time, and got a response that worked from rems. See How can I set up Postfix so that all email sent on my dev box gets routed to the developer email group?

share|improve this answer

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