procmail
[Top] [All Lists]

Re: set a different exitcode for each mailbox

2007-09-21 07:50:48
Am 2007-09-20 01:31:05, schrieb M. Fioretti:
Sorry, still me. I have realized that probably I don't really need to
deliver to folder_N from within procmail. 

I still need to process those messages with procmail because I must do
a lot of checks which are either procmail recipes I have and don't
want to re-implement in other languages, or things for which procmail
is simply much better than any other alternative.

But maybe I just need procmail to analyze the message, tell the
calling script which one of the recipes matched and terminate WITHOUT
delivering anything: I'm working on maildirs, so I can mv messages to
the right folder and/or process them in other ways in the script, if
only procmail tells me which recipe matched.

Therefore, if I understand correctly the documentation, what I need to
do is take the procmailrc file above and replace EVERY folder name,
INCLUDING the default one at the end, with four lines like these:

{
    EXITCODE=N # with a different value of N for every recipe
    HOST
}

Does this make sense? If yes, which ranges of N must be avoided,
because they correspond to procmail error codes which signal something
bad happened? I've tried to google "procmail error codes", but didn't
find anything useful

----8<----------------------------------
MAILDIR=${HOME}/.prog_cnf/output
DEFAULT=${HOME}/.prog_cnf/output/

:0f
* some_condition
|some_filter

:0f
* another_condition
|another_filter
----8<----------------------------------

then do in your script:

----8<----------------------------------------------------------
  rm -f ${HOME}/.prog_cnf/output/*/*
  cat ${MSG} |procmail above_procmail_rc
  ES=$?
  if [ ${ES} -eq 0 ] ; then
    FILE=$(ls ${HOME}/.prog_cnf/output/*/* 2>/dev/null)
    ...
    ...
  else
    echo "$(basename $0): procmail exited with error ${ES}" 1>&2
    exit $((127+ES))
  fi
----8<----------------------------------------------------------

which mean. if procmail has filtered without any errors, your
script can pick the resulted file in the DEFAULT directory.

Thanks, Greetings and nice Day
    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