Codingdomain.com

Automatic mail processing

Sorting messages

With the help of Maildrop's filtering syntax, messages can be delivered to different e-mail folders.

These expressions filter on fields in the message headers. These headers can be made visible with the "view source" option in an e-mail client.

Message sorting: ~/.mailfilter
# Verify whether the message is
# retrieved from gmail
#
if(  /^Received: from pop.gmail.com .* with POP3/  )
{
  if(  /vdboor@gmail\.com/  )
  {
    log "---- to gmail"
    to "$MAILBOX/.gmail/"
  }
}


# Verify whether the message is
# retrieved from codingdomain
#
if(  /^Received: from mail.codingdomain.com .* with POP3/  )
{
  # messages with a X-Bugzilla header field
  if(  /^X-Bugzilla-/  )
  {
    log "---- X-Bugzilla"
    to "$MAILBOX/.codingdomain.fora/"
  }

  # messages addressed to kmess-devel
  if(  /kmess-devel@lists\.sourceforge\.net/  )
  {
    log "---- kmess-devel at lists.sourceforge.net"
    to "$MAILBOX/.codingdomain.sourceforge/"
  }

  # messages addressed to vdboor@codingdomain
  if(  /vdboor@codingdomain\.com/  )
  {
    log "---- vdboor at codingdomain.com"
    to "$MAILBOX/.codingdomain.vdboor/"
  }
}

The following method is more precise, but also less flexible:

Filter the to field: ~/.mailfilter
foreach /^To: .*/
{
  TO_LINE="$MATCH"
  foreach (getaddr $TO_LINE) =~ /.+/
  {
    EMAIL=lolower("$MATCH")
    if($EMAIL eq "me@here.com")
    {
      to "$MAILBOX/.mymail.here/"
    }
    if($EMAIL eq "me@there.com")
    {
      to "$MAILBOX/.mymail.there/"
    }
  }
}

Related articles