[Mimedefang] Help filtering by recipient (To: Line)

Jim McCullars jim at info.uah.edu
Mon Jul 11 16:02:07 EDT 2005

On Mon, 11 Jul 2005, Bradley Glonka wrote:

> I want to silently discard emails that are sent to a few certain addresses.
> To be clear I want to filter by addresses that appear on the the To: Line

   Note that any recipient variables set by MIMEDefang refer to the
sendmail envelope recipient, which is not necessarily the same as the
value on the "To:" header.  To examine that, you need to open the HEADERS
file and find the "To:" header and see if it has the values you want and
discard accordingly.

   If, as in your example, you want to discard any emails that have
donotsendto at email.com in the "To:" header, you would do something like
this (in filter_begin()):

  if(open(IN, "./HEADERS")) {
    while (<IN>) {
      if (/^To:.+donotsendto\@email\.com/i) {
        return action_discard;


Jim McCullars
University of Alabama in Huntsville

More information about the MIMEDefang mailing list