A little more digging sound a clever variant on this, in one of the
places I'd looked earlier but hadn't found what I was looking for, but
with Simon's information I was able to piece things together..

http://pm-doc.sourceforge.net/pm-tips-body.html#how_to_raise_a_flag
illustrates Simon's technique, but then gives something better that
I'm using instead: procmail will set the LASTFOLDER variable if it
delivers the mail, so I can use that to test if the message was
delivered.

My rc.lists (called from .procmailrc) now looks like this:

# Unset LASTFOLDER variable - if the message is delivered, this will be reset
LASTFOLDER

:0c:
* [EMAIL PROTECTED]
 lists/security/focus-ms
<snip>
:0c:
* [EMAIL PROTECTED]
 lists/SLUG
<snip>
# If any of the above matched, LASTFOLDER will be set
:0
* ! LASTFOLDER ?? ^^^^
! [EMAIL PROTECTED]

Works nicely, looks prettier, and avoids the expensive call out to test..

On 7/11/05, Simon Bowden <[EMAIL PROTECTED]> wrote:
> On Mon, 11 Jul 2005, James Polley wrote:
> 
> > I have a bunch of procmail recipes that pick up mail for various
> > mailing lists I'm on and dump it to specific folders:
> >
> > :0:
> > * [EMAIL PROTECTED]
> > lists/security/linux-secnews
> >
> > :0:
> > * [EMAIL PROTECTED]
> > lists/SLUG
> >
> > I'd like for any mail that matches one of these rules to also be
> > forwarded to my gmail.
> <snip>
> >
> > However, I want this last action to happen if any of the preceding rules ma=
> > tch
> >
> > Does anyone know if this is possible?
> 
> Hi James,
> 
> I use a structure like this, which could be extended to your needs. My
> requirement is that all amil to a mailing list goes to its box. PLUS, if
> it is directly to me or didn't land in a mailing list box, then it also
> goes into my inbox.
> 
> The main point is using a variable to mark if it's delivered, then forward
> or deliver elsewhere at the end depending on the value of the variable.
> Someone else may have a neater-looking solution though...
> 
> The structure is also useful for subfiltering or archiving some lists.
> 
> ======================================
> # This variable is used to mark if a message is delivered
> # We deliver to all sub-boxes, but don't repeat anything into inbox
> DEL=0
> 
> # spam and dupe killing rules go first, and are terminating, but are
> # excluded from this sample
> 
> # Mail directly to me
> * ^TO.*(regexp)@my.addresses
> {
>    DEL=1
> 
>    :0 c:
>    $DEFAULT
> }
> 
> # SLUG
> :0
> * ^Subject.*\[SLUG\]
> {
>    DEL=1
> 
>    :0 c:
>    SLUG
> }
> 
> ... (more similar rules) ...
> 
> # Everything else will fall through to my inbox
> :0
> * ? /usr/bin/test $DEL -eq 0
> $DEFAULT
> 
> # Anything here (DEL != 0) was already delivered to another mailbox
> # You would probably not deliver to /dev/null until you are confident of
> # your rules
> :0
> *
> /dev/null
> =====================================
> 
> Cheers,
> 
>   - Simon
> 


-- 
There is nothing more worthy of contempt than a man who quote himself
in his email footer - Zhasper, 2005
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to