procmail
[Top] [All Lists]

RE: Checking Message-Id: cache without updating?

2003-01-13 19:05:43
Christopher P. Lindsey wrote:

   I'm using procmail as a wrapper around mailing lists.  Previously
   I had been using the standard formail recipe before calling the
   MLM, i.e.

      :0 Wh: $HOME/list-cache/${LIST}.lock
      | formail -D 32768 $HOME/list-cache/${LIST}.cache

   This generally works well unless the MLM fails for some reason.  At
   that point I requeue the messages, but they're already in the 
   cache and will fail on subsequent delivery attempts.

   OK, no problem.  I figured that I'd only call formail -D 
if delivery
   to the MLM was successful.  Before calling the MLM I'd just grep 
   in the cache to see if it was there or not.  i.e.

      :0
      * ! ^Approved:
      * ^Message-Id: \/.*
      * ? fgrep -q "$MATCH" $HOME/list-cache/${LIST}.cache
      /dev/null

[I've deleted your MLM wrapper.]

That above seems unnecessarily costly to me.  Why not just put
a semaphore condition in the Message-ID:-cache recipe?

I have a redeliver alias that works well for me.  This is Csh-y syntax:

% grep redel ~/.aliases 
alias redel  'sh -c "formail -s procmail TEST=y HARNESS=y \\
                        REDELIVER=y 2>&1" <\!^'

The point here isn't the alias itself, though you can feel free to use
it if you like.  But the point is the variables it inserts when it
calls procmail.  Of main import here is my TEST variable.  Then,
in my msgid-cache recipe, I have

  *  ! TEST  ??  ^^(y|on)

For general interest, I'll state very briefly the rest of the alias's
function.  HARNESS's being set invokes a shunt around my LOGFILE
assignment in my .procmailrc.  Thus, when I'm running a "test-harness"
mode, output of procmail's action is to stdout, which usually equates
to my terminal.  (I can also set HARNESS to specific section names
in my rc.  This has the function of causing output for that section
only to be in verbose mode.)

REDELIVER overrides the flags elsewhere in my rc that recognize
test-harness mode and don't ever deliver things.  If I set REDELIVER
on, they *do* deliver, as if the mail were new.

I run the commands in a Bourne subshell, so that I can easily redirect
stderr to stdout.  That allows me to grep the "log" output right
on the terminal, for repetitive or specialized test-harness ("sandbox,"
as Sean calls it) operation.

Okay, enough about the alias.  Just tell your msgid cache to abort
on mail you're redelivering, and you'll be fine.



   This works for the most part, but there are times when the 
Message-ID has special characters that mess up the matching.  


You need to special-quote your grep argument, if you still insist on
using it.  (The solution has nothing to do with sed.)

        fgrep -qs -e "'"$MATCH"'"

And maybe you also want the -w there.  The -e should go last.

Dallman

-- 

"If you find a path with no obstacles, it probably does not lead to
anywhere."
        Thoughts of Rev. Sunnan Kubose, from _Zen in the Markets_  


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>