procmail
[Top] [All Lists]

Re: How to auto-process emails based with header?

2010-10-19 20:18:57
On Wed, 20 Oct 2010 03:54:55 +0800, Michelle Konzack <linux4michelle(_at_)tamay-dogan(_dot_)net> wrote:

Hello Yue Wu,

Am 2010-10-19 09:13:13, hacktest Du folgendes herunter:
Thanks for so patience and so kind of you!
I've tried it, it works somehow, but...:
1. it says errors when processing:
    LISTNAME: Undefined variable.
2. It filters all other mails into .Malinglists., though I've put the
rule in front of my other rules. I tried the following rule but with
no lucky:

Change the two lines:

:0
.Mailinglists.${LISTNAME}/

to:

  :0
  * ? test -n "${LISTNAME}"
  .Mailinglists.${LISTNAME}/

Which mean, if the previously recipes detect a valid LISTNAME only then,
the messages  is  saved  into  .Mailinglists.${LISTNAME}/  otherwise  it
continue wit the rest of the procmailrc


Now it works, but still has many "LISTNAME: Undefined variable."...

Following is my modified config:


#=====================================================================
# Get the listname
#=====================================================================

:0
* ^List-Post:.*mailto:[-(_dot_)(_at_)a-zA-Z0-9]+>
* ^List-Post:.*mailto:\/[-(_dot_)(_at_)a-zA-Z0-9]+
{ LISTNAME="${MATCH}" }

#-----------------------------------------------------------------

:0E
* $ ^X-Mailing-List:.*[${ST}]\/.*
{ LISTNAME="${MATCH}" }

#-----------------------------------------------------------------

:0E
* $ ^X-BeenThere:.*[${ST}]\/.*
{ LISTNAME="${MATCH}" }

#-----------------------------------------------------------------

:0E
* $ ^Sender:.*[${ST}]\/.*
{ LISTNAME="${MATCH}" }

#-----------------------------------------------------------------

:0E
* $ ^List-ID:.*[${ST}]<[-.a-zA-Z0-9]+>
* $ ^List-ID:.*[${ST}]<\/[-.a-zA-Z0-9]+
{ LISTNAME=`echo "${MATCH}" |sed 's|\.|@|' ; :` }

#-----------------------------------------------------------------

#=====================================================================
#  Filter into the folders
#=====================================================================

LISTNAME=`echo "${LISTNAME}" |tr '.' '_' |sed 'y|ABCDEFGHIJKLMNOPQRSTUVWXYZ|abcdefghijklmnopqrstuvwxyz|' |sed -e 's|-bounces@||' ; :`

:0
* ? test -n "${LISTNAME}"
.Mailinglists.${LISTNAME}/

--
Regards,
Yue Wu

Key Laboratory of Modern Chinese Medicines
Department of Traditional Chinese Medicine
China Pharmaceutical University
No.24, Tongjia Xiang Street, Nanjing 210009, China
____________________________________________________________
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