Hi list!
I'm trying to sort my incoming mails which include mails from various
mailing lists to separate mailfolders using procmail.
All my mailing lists include their name in mail subject enclosed in
square brackets: for example '[mythtv-cz]'.
So i wrote a procmail recipe, which matched '[mythtv-cz]' from mail
'Subject:' header. It looks like this and works fine:
# mythtv-cz mailing list
:0:
* ^Subject.*\[mythtv-cz\]
mythtv-cz/
But often, mail subjects are rfc-2047 encoded (due to non-ascii chars in
them, looks like this: Subject: =?iso-8859-2?B?a2FsZW5k4fg=?=) and don't
match the filtering condition.
So i wrote a small perl script, which decodes the subject for me, assigns
it to variable and i now try to match the mailing list name against this
variable. My complete procmailrc looks like this:
PATH=/bin:/usr/bin
MAILDIR=$HOME/.maildir/
DEFAULT=$MAILDIR/pantaril/
LOGFILE=$MAILDIR/logs/log.`date +%y-%m-%d`
SHELL=/bin/sh
#decode subject
SUBJECT=`formail -xSubject: | $HOME/bin/decode_header`
LOG="SUBJECT: $SUBJECT
"
# mythtv-cz mailing list
:0:
* SUBJECT ?? \[mythtv-cz\]
mythtv-cz/
The SUBJECT is decoded corectly, i can see it clearly in my log. But the
matching condition (* SUBJECT ?? \[mythtv-cz\]) now matches ALL mails,
everything ends up in my mythtv-cz mailfolder.
The problem is in the square brackets. If i remove them (* SUBJECT ??
mythtv-cz) everything works as expected, but i want to match the mailing
list name with the brackets included.
So can someone explain to me, what am i doing wrong? I tried to remove the
escape slash or to add double escape in front of the brackets but there is
no diference.
Here is some sample LOG output from my testing:
$ echo "ahoj" | mail -s "[mythtv-cz]test" pantaril
log output:
SUBJECT: [mythtv-cz]test
From miceke(_at_)valachnet(_dot_)cz Fri Mar 12 11:42:40 2010
Subject: [mythtv-cz]test
Folder: mythtv-cz/new/1268390560.16977_1.pc87.valachnet.cz
$ echo "ahoj" | mail -s "[whatever]test" pantaril
log output:
SUBJECT: [whatever]test
From miceke(_at_)valachnet(_dot_)cz Fri Mar 12 11:42:55 2010
Subject: [whatever]test
Folder: mythtv-cz/new/1268390575.16988_1.pc87.valachnet.cz
Any help would be appreciated.
Emil Micek
____________________________________________________________
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