Solved

filtering outgoing mail from based on "to" field with postfix

Posted on 2011-02-11
1
950 Views
Last Modified: 2012-05-11
I am trying to filter all outgoing mail based upon the "to" header. We use a relay for all outgoing mail. I think using header_checks is the best way, but I cannot get that to work. Is the following header check correct?

!/[Tt][Oo].*@ourdomain\.com/ DISCARD not being sent to ourdomain.com

Open in new window


I am attempting to discard all mail that isn't sent to an email addressing ending in "@ourdomain.com"

I haven't been able to get it work. No matter what gets sent, it discards it. I think this is due to the fact that the header_checks does it line by line, not the entire header. This means that it first checks the main header (i.e. received: by r110.ourdomain.com (Postfix, from userid 518)??id 5AA935C60233; Fri, 11 Feb 2011 17:48:55 -0500 (EST)), to field (i.e. To: jbarnett@ourdomain.com), etc...

I believe it's rejecting all mail because it first checks out the top header by itself, sees that it doesn't contain @mydomain.com and rejects it right then and there. Is there a way to limit the header checks to the "To" field?

The following provides me with the information leading me to believe that it's getting hung up on the top header, as well as I've checked the logs and I see it checking the top header and then rejecting mail.
BUGS
       Empty lines never match, because some map types mis-behave
       when  given  a zero-length search string.  This limitation
       may be removed for regular expression tables in  a  future
       release.

       Many  people  overlook  the main limitations of header and
       body_checks rules.

       o      These rules operate on one logical  message  header
              or one body line at a time. A decision made for one
              line is not carried over to the next line.


Thanks!
0
Comment
Question by:jasonatspigit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
jasonatspigit earned 0 total points
ID: 34876092
I finally figured it out. I corrected the statement to the following so it would pass on the other header lines.

!/(Received: by|[Tt][Oo].*@spigit\.com|subject:)/ DISCARD not being sent to spigit.com

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reject incoming email for specific user - postfix 10 72
Windows 10 linux VM 30 92
DB2 9.7 Grant Execute SP 4 60
How to check if the Cron job is running or not ? 12 82
New-MailboxSearch Powershell Command and step by step approach to Search and Extract Emails form Exchange 2013 Journaling server.
Import PST to Exchange using Power Shell new-mailboximportrequest command, you can simply import the PST file into Exchange mailbox or archived. To know How to import PST into Exchange  2013 read the complete article.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to moveā€¦

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question