Thursday, February 7, 2013

Block emails sending out to a particular domain

How to block sending and receiving emails from/to specific domain? Like:

  • AOL
  • Gmail
  • Hotmail
  • etc.

I will not use smtpd_sender_restrictions from Postfix, but create simple rule in MSH Traffic Policy.

1. The easiest way to do this is to create rule with block message action.
Block Message action.

2. Choose REJECT option.
Choose REJECT option from TYPE drop down menu.

3. Now go to Conditions tab and define domains which you want to block. For this example I'll use * Select Message Sender condition from the list.
Message Sender condition.

4. Add domain with asterisk character which will match any email address.
Sender email address.

5. Select Message Recipient conditions from the list.

Message Recipient condition.

6. Add domain with asterisk and choose TO,CC and BCC option from drop down menu - with this none email will go through this filter.

In which fields search: TO, CC and BCC

7. Remember to select Any condition must met - with this option when only one condition is met message will be dropped.
Any condition must met to block message.

With that created rule no mail will go to or from domain. There is no limit of defined domains, so adding new one is as easy as previous one.