-   Linux - Server (
-   -   Postfix: block outgoing mail to any domain except one (

bas_at_cipix 05-10-2012 09:25 AM

Postfix: block outgoing mail to any domain except one
We have a development server for web development. The websites may send (automatic) e-mails from time to time. We want to make sure that e-mails sent by these websites on the development server are blocked by postfix, so that they are never sent over port 25 at all, but simply discarded, except for if it is sent to our own domain

I've tried to use postfix for this purpose but I just can't get it to work.

I tried rejecting everything in smtpd_sender_restrictions and smtpd_recipient_restrictions, but when I execute "mail" the e-mails are sent.

Is there ANY way to do this and how?

ceyx 05-10-2012 04:13 PM

You might look at iptables. Block port 25 to all but your specific IP.

There are lots of how-to's out there. This one may give you some hints : ( ie modify # 9 from port 22 to port 25 )

Noway2 05-11-2012 09:50 AM

The problem with blocking the domains with IPTables is that you will build up a massive queue of outbound emails that Postfix will attempt to deliver for 60 days. You really need to get the Sender Restrictions to work. I realize that you tried this approach without success, but I can't comment on your approach without additional details. This will require a combination of a (outbound) recipient list that pattern matches the domain, followed by a reject everything else created with a combination of a filter file and the restrictions put in place in your file.
I think you want to use either "reject_unlisted_recipient" or "check_recipient_access". Whether or not these will block everything else will then depend upon your settings in At a minimum, I think you will need to use "smtpd_reject_unlisted_recipient". See the following page for details:

All times are GMT -5. The time now is 10:14 AM.