5

I am having Postfix installed mailserver and I am using that server for legitimate purpose only.

I need to block some outgoing emails for a particular blacklisted domain. Is there anyway to do through the configurations ?

Your help is greatly appreciated.

Thanks in advance Karthick

karthick
  • 683
  • 3
  • 7
  • 14

1 Answers1

10

A closer look at the basic access controls available should help you out; just specify the appropriate access map in smtpd_recipient_restrictions that denies access to those domains:

smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/blacklisted_domains, permit_mynetworks, reject_unauth_destination, permit

and in /etc/postfix/blacklisted_domains:

bad.domain1    REJECT
bad.domain2    REJECT
baduser@bad.domain3    REJECT

Don't forget to postmap that file.

adaptr
  • 16,576
  • 23
  • 34
  • This does not work for TLDs (example: .biz, .info) – Overmind Aug 20 '18 at 11:25
  • This works from Thunderbird, I blocked some email addresses and I get an error. However, when sending from PHP, the emails go through. How do we also block the PHP `mail()` (mine is setup to use SMTP). – Alexis Wilke Mar 14 '20 at 20:48