Postfix – Block Senders Outside Local Domains

blockemailpostfixspam

I would like to block every mail that is coming in from a domain that is running on my server.

Example: I have domain1.com on my mail server and I'm getting a mail from outside with an email address of JohnDoe@domain1.com Then I know it's a Spam, because domain1.com is on my server, so the sender cannot come from outside.

I want postfix to check for this, and simply block these kind of emails.

I know this is a function in postfix, just don't know which one.

Thanks.

Best Answer

Of course the sender can come "from outside"; you need to think carefully about what that actually means.

What if a user submits mail from outside your network ? You don't specify if this is possible.

This is easy if you use submission for all user submission of mail, and only use port 25 for inter-MTA traffic; in that case, simply disallow your local domains using a check_sender_access map:

smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination, check_sender_access hash:/etc/postfix/local_domains

and in /etc/postfix/local_domains:

example.org REJECT
example.net REJECT

etc.

Don't forget to postmap the file whenever you change it:

postmap /etc/postfix/local_domains   
Related Topic