Re: How to filter emails based on both To: and From:
- Thank you Mouss!
Your solution has proved to be the right one!
Ralf Hildebrandt wrote:
* Narancs <narancs3@...>:Dear Ralf,
We are running postfix 2.3.2 as an internet mail gateway like this:
Internet <-> Mailgw <-> company M$ Exchange SMTP on private network.
Due to a bug in MS systems, whenever a company local user sends an email
to a non-existent other local user (user exists in the AD, but doesn't
have a mailbox for some other reasons), then MSexch wants to send the
email through the relay_host which is the mailgw. Mailgw decides to send
back the mail to the exch as its transport table says so and a mail loop
Simply give the relay a list of recipients and you're done.
relay_recipient_maps. See my book.
Well we've got hundreds of users and the list cannot be maintained, as they are changing frequently.
AD/LDAP lookup is neither an option, just as I wrote, the win domain user exists, but has never used his/her email so no mailbox is created.
By default all users/employers are granted company email access due to the company policy, but a lot of technical/field engineers just never log in to the network, but when they're employed, their account is created.
/so I need a solution that if the sender's (from:) and the recipient's domain is the same, and it's our domain, the email is to be discarded./
It's like headers_check, but multi-line intelligence.
why headers? why not use the envelope sender and recipient?
In short, the MS Exchange (called msex below :) box should not send mail to the domains it handles, right? so use:
smtpd_restriction_classes = catch_broken_msex
where 10.1.2.3 is the IP of the exchange box. duplicate the line if it uses multiple IPs.
if REJECT causes trouble, try DISCARD, but I don't like discarding mail...