Make Postfix reject emails if mail() "FROM:" header domain has not hosted or whitelisted on virtualmin server.

1 post / 0 new
#1 Tue, 11/15/2016 - 09:07
pragma

Make Postfix reject emails if mail() "FROM:" header domain has not hosted or whitelisted on virtualmin server.

Hi,

I am configuring virtualmin for my new server because old server was hacked and thus blacklisted due to mass email sending.

I am looking for a way like if any script is trying to send email them postfix can check if "FROM" header, if matched with hosted domain else, reject the email.

Example: Let's say example.com is hosted on my Virtualmin server

  1. Postfix should allow to send emails if mail() header has "From: admin@example.com" or "From: anything@example.com" or "From: anything@stage.example.com"
  2. Postfix should reject emails if mail() header has "From: admin@test.com" or "From: anything@gmail.com" or any other domain which isn't hosted on my server.

Also, it there any way I can set mail sending limit per hour for any domain/server?

Note: I have already configured SPF, DKIM and DMARC and logging the path of any files from emails would be sending so that I can track them:

mail.add_x_header = On
mail.log = /var/log/phpmail_files.log