Postfix Spam Control

Reject / Discard / Redirect emails based on header checks :

vi /etc/postfix/main.cf
header_checks = regexp:/etc/postfix/header_checks

vi /etc/postfix/header_checks
/^From: "Mechanic/ REJECT
/^To: someone@example.com/ REDIRECT someone@example2.com
/^To: bademail@example.com/	REJECT
/^Subject: .*badWord/	DISCARD

Reject By Subnet Range (CIDR)

Add  to the recepient restriction in the main postfix configuration file :

vi /etc/postfix/main.cf
smtpd_recipient_restrictions = check_client_access cidr:/etc/postfix/block.cidr

Now create the block.cidr file and add any ip ranges in the CIDR format that you may want to block :

vi /etc/postfix/block.cidr
192.168.0/24          REJECT

 

Note : The postfix needs to be reloaded in order to re-read the changes in block.cidr file