Loading ...
Sorry, an error occurred while loading the content.

Re: How to filter emails based on both To: and From:

Expand Messages
  • Narancs
    Thank you Mouss! Your solution has proved to be the right one! Regards, N. mouss wrote: Narancs wrote: Ralf Hildebrandt wrote: * Narancs
    Message 1 of 9 , Aug 1, 2007
    • 0 Attachment
      Thank you Mouss!

      Your solution has proved to be the right one!

      Regards,
      N.

      mouss wrote:
      Narancs wrote:

      Ralf Hildebrandt wrote:
      * Narancs <narancs3@...>:
       
         Dear All,

         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
         is created.
         

      Simply give the relay a list of recipients and you're done.
      relay_recipient_maps. See my book.

       
      Dear Ralf,

      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

      smtpd_recipient_restrictions =
         check_client_access hash:/etc/postfix/msex_acl

      catch_broken_msex =
         check_recipient_access hash:/etc/postfix/msex_domains

      == catch_broken_msex
      10.1.2.3      catch_broken_msex

      where 10.1.2.3 is the IP of the exchange box. duplicate the line if it uses multiple IPs.

      == msex_domains
      mydomain.example      REJECT

      if REJECT causes trouble, try DISCARD, but I don't like discarding mail...
    Your message has been successfully submitted and would be delivered to recipients shortly.