LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Postfix: block outgoing mail to any domain except one (http://www.linuxquestions.org/questions/linux-server-73/postfix-block-outgoing-mail-to-any-domain-except-one-944239/)

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 XXXXX.nl.

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 someone@gmail.com" 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 : http://www.thegeekstuff.com/2011/06/...ules-examples/ ( 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 main.cf 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 main.cf. At a minimum, I think you will need to use "smtpd_reject_unlisted_recipient". See the following page for details: http://www.postfix.org/postconf.5.ht...sted_recipient


All times are GMT -5. The time now is 12:54 PM.