procmail
[Top] [All Lists]

The escaped From bugaboo

2013-01-13 15:08:31

I got an email today with this paragraph in it:

***
These new “post-Panamax” ships are the length of aircraft carriers.
From the waterline, they’re 190 feet tall, or nearly twice the height
of the Lincoln Memorial. The ships can carry as many as 12,000
containers, or about a million flat-screen TVs.
***

As you can see, the "From" is escaped.

I'm not sure why this continues to happen, and it happens on an email that is 
delivered without a .procmailrc, which makes me think the issue is in the 
default procmailrc. The only part that modifies the original message is the 
formail to add the X-Hostname header.

cat /usr/local/etc/procmailrc 
DATE=`date '+%Y%m%d%H%M%S'`
LOGFILE=/var/log/procmail
LOGABSTRACT=NO
HOSTNAME=`hostname`
NL="
"
WS="  "

:0c
{
        :0
        /backup/imap.backup/
}

:0
{
  INCLUDERC=/usr/local/etc/furrin.rc

  LOG="SPAM:${NL} ${SPAMVAL}${NL} ${SPAMMISHNESS}${NL} ${SPAMNOTES}${NL}"
}

:0fw
| formail -I"X-Hostname: $HOSTNAME"

# from Sean B Straw
# provide FROM_USER, FROM_DOMAIN, SUBJECT, TO, FROM, ENVTO, ENVFROM

:0
{
        :0
        * $ ^Subject:$WS*\/[^$WS].*
        { SUBJECT=$MATCH }

        :0
        * $ ^To:[$WS]+\/[^$WS].*
        { TO=$MATCH }

        :0
        * $ ^From:[$WS]+\/[^$WS].*
        { FROM=$MATCH }

        # This is an optional header - your MTA configuration may not insert
        # it (bummer for you).  It is very useful to have
        :0
        * 9876543210^0 ^X-Original-To: *<\/[^>]*
        * 9876543210^0 ^X-Envelope-To: *<\/[^>]*
        { ENVTO=$MATCH }

        # This is also an optional header.  If you don't have this, you can
        # get the same information through the commented out rule which
        # follows.
        :0
        * ^X-Envelope-From: *\/[^$WS].*
        { ENVFROM=$MATCH }

        # alternative to X-Envelope-From:
       :0
       * ^From \/[^ ]*
       { ENVFROM=$MATCH }

        # Here we have to call shell.... -rt will parse return address
        # according to RFC rules.  Note we only process HEADER.
        :0 h
        SENDER=|formail -b -rtzxTo:

        # get the From: address as an address component ONLY (no comments)
        :0 h
        CLEANFROM=|formail -IReply-To: -rtzxTo:

        # username portion
        :0
        * CLEANFROM ?? ^\/[^@]+
        { FROM_USER=$MATCH }

        # domain portion
        :0
        * CLEANFROM ?? @\/.*
        { FROM_DOMAIN=$MATCH }

        :0
        * FROM_DOMAIN ?? .*\/([^\.]+)
        { TOPD = $MATCH }
        :0
        * Received:.*from \/.*by mail.covisp.net
        * MATCH ?? ^^\/[^)]+
        { DFROM = $MATCH }


     # Obtain the hostname of the host which relayed the message to us.
     # This is found in the topmost received header.
     
     RELAYHOSTX=`formail -u Received: -czx Received:`
     
     # The hostname provided in the SMTP EHLO exchange will be the first
     # token on this line.
     :0
     * RELAYHOSTX ?? ^from \/[^    ]*
     {
     RELAYHOSTEHLO=$MATCH
     }
     
     # Then isolate the hostname portion (if any) in the parenthetical.
     :0
     * RELAYHOSTX ?? ^from [^   ]* \(\/[^)]*\)\>+by\>
     * MATCH ?? ^\/[^)]+
     {
     RELAYHOSTX=$MATCH
     
     :0
     * RELAYHOSTX ?? ^\/[^[ ]+
     {
     # grab whatever up to the first space or the open
     # brackets for the IP
     RELAYHOST=$MATCH
     }
     
     :0
     * RELAYHOSTX ?? ()\[\/[^] ]+
     {
     # grab the apparent host IP from the brackets
     RELAYHOSTIP=$MATCH
     }
     }
     
     # null out RELAYHOSTX (temp variable used in the extraction process)
     RELAYHOSTX=
     
     # if the relay host has no rDNS, RELAYHOST should be undefined.
}

LOG="RELAYHOSTEHLO=$RELAYHOSTEHLO RELAYHOSTIP=$RELAYHOSTIP $NL"

# the RELAYHOSTELHO should match against all known aliases for your host
# - the IP(s), the hostname(s), and localhost.  RELAYHOSTIP should be the
# IPs and localhost IP (127.0.0.1).
:0
* RELAYHOSTEHLO ?? (75\.148\.117\.93|(mail|akane)\.covisp\.net|localhost)
* ! RELAYHOSTIP ?? (75\.148\.117\.93|127\.0\.0\.1)
{
      :0 fw
      | formail -I"X-Host-RCVD: Foreign sender using our hostname or IP for 
submission${NL}"
}

LOG=$NL"$DATE: TOPD=\"$TOPD\", 
FromU=\"$FROM_USER\", DFrom=\"$DFROM\", FromD=\"$FROM_DOMAIN\", 
Subject=\"$SUBJECT\", Relayhost=\"$RELAYHOST\",
To=\"$TO\", From=\"$FROM\", EnvTo=\"$ENVTO\", EnvFrom\"$ENVFROM\"$NL"

:0  
* ! ? test -f $HOME/.procmailrc
{
  LOG="User has no procmailrc LOGNAME=$LOGNAME@$HOST HOME=$HOME$NL"
  :0 fw
  | /usr/local/bin/spamc -u $LOGNAME

  DROPPRIVS=YES
  DEFAULT=$HOME/Maildir/

   :0 
   * ^X-Spam-Status:(.*\<)?Yes
   {
      :0
      { TRAP='mv "$LASTFOLDER" "${LASTFOLDER}:2,S"' }

      :0
      .SPAM/
   }

   :0
   $DEFAULT
}
LOG="User $LOGNAME@$HOST has a .procmailrc, processing...$NL" 

There are no errors thrown by this file,a dn the log looks just as I would 
expect:

FromU="root", DFrom="", FromD="covisp.net", 
Subject="Test", Relayhost="",
To="faker(_at_)covisp(_dot_)net", From="root(_at_)covisp(_dot_)net (Charlie 
Root)", EnvTo="", EnvFrom"root(_at_)covisp(_dot_)net"
User has no procmailrc LOGNAME=faker(_at_)mail(_dot_)covisp(_dot_)net 
HOME=/home/faker

and the email has the from line escaped as above.


-- 
Well boys, we got three engines out, we got more holes in us than a
horse trader's mule, the radio is gone and we're leaking fuel and if we
was flying any lower why we'd need sleigh bells on this thing... but we
got one little budge on those Roosskies.  At this height why they might
harpoon us but they dang sure ain't gonna spot us on no radar screen!


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>