procmail
[Top] [All Lists]

Re: MIME headers in Procmail

2011-07-11 11:59:53
John Levine wrote:

Hm, this more or less seems to work.  Ugh.

:0 H
SUBJ=| formail -fXsubject -Xfrom |perl -MEncode -ne 'print 
encode("UTF8",decode("MIME-Header",$_))'

I know next to nothing about perl, but can't it discard the other lines besides Subject: and From: and save the calls to formail and the shell?

:0 ci
* SUBJ ?? Subject:\/.*
| echo "subject is $MATCH"

Where is the output of echo going?  If you're writing it to the logfile,

 :0c
 * SUBJ ?? Subject:\/.*
 LOG="subject is $MATCH
"

will be a bit more streamlined. I'd recommend that for "from is" as well, but also,

:0 ci
* SUBJ ?? From:\/.*
| echo "from is $MATCH"

Just in case "From:" appears in the subject and Subject: precedes From:, you should left-anchor the regexp in that condition:

 * SUBJ ?? ^From:\/.*

Then there's the matter of the spaces that almost always follow the colons, but I won't get into that.

____________________________________________________________
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>