procmail
[Top] [All Lists]

Re: processing inbox maildirs with formail

2007-09-03 10:00:44
Hello Marco,

I do some similar things but...

Am 2007-08-27 16:53:11, schrieb M. Fioretti:
##################################################################
#! /bin/bash

cd /the/maildir/base/directory/
for file in cur/*
  do
  /usr/bin/formail -s /usr/bin/procmail -m test/rcfile.rc < $file
  #rm or mv $file
  done
for file in new/*
  do
  /usr/bin/formail -s /usr/bin/procmail -m test/rcfile.rc < $file
  #rm or mv $file
  done

Make it more simpel:

----8<--------------------------------------------------------------
for FILE in $(find ${WAITING} -type f) ; do
  if [ -n "$(grep '^X-I-WAS-ALREADY-PROCESSED: yes' ${FILE})" ] ; then
    procmail <${FILE}
    if [ $? -eq 0 ] ; then rm -f ${FILE} ; fi
  fi
done
----8<--------------------------------------------------------------

and your procmailrc file:

----8<--------------------------------------------------------------
SHELL=/bin/sh
PATH=/bin:/usr/bin:/usr/bin
MAILDIR=/all/mail/base
LOGFILE=/var/log/procmail_test_logs/PROCMAIL.log
LOGABSTRACT = "all"
VERBOSE     = "on"
DEFAULT     = "$MAILDIR/.test_output/"

:0
* ! ^X-I-WAS-ALREADY-PROCESSED: yes
* <some_criteria_which_enforce_waiting>
{
  FOO= formail -f -I "X-I-WAS-ALREADY-PROCESSED: no"
  :0
  .waiting/ 
}

:0
* To:.*${LIST1}
.List_1

:0
* To:.*${LIST2}
.List_2
----8<--------------------------------------------------------------

Now, if a mail comes in which fit <some_criteria_which_enforce_waiting>
it will get an Extra-Header "X-I-WAS-ALREADY-PROCESSED: no" and you can
process the Mailfolder ".waiting/" as you like.

After processing your Processing-Tool should change the Extra-Header to
"X-I-WAS-ALREADY-PROCESSED: yes" and your cronjob will check it.

If the script fine the String "X-I-WAS-ALREADY-PROCESSED: yes" it will
push the message through the original procmailrc again.

Greetings
    Michelle Konzack
    Systemadministrator
    Tamay Dogan Network
    Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack   Apt. 917                  ICQ #328449886
                   50, rue de Soultz         MSN LinuxMichi
0033/6/61925193    67100 Strasbourg/France   IRC #Debian (irc.icq.com)
____________________________________________________________
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>