procmail
[Top] [All Lists]

Re: proper use of 'e'

2002-08-01 08:00:49
Apologies if this comes to the list a couple of times...had a small
mail-relay/thunderstorm incident.


Is this the proper recipe?

# (1) If message is to me
:0c:
* $ ^(To|Cc):.*$ME
$HOME/mail/zbackup

# (2) message is NOT to me
:0Ec:
$HOME/TEMP/zbackup.not2me/

# (3) can't save in TEMP/zbackup.not2me, then
:0ec:
$HOME/TEMP/zbackup.not2me.failed

# (4) worst case scenario:
# can't save in TEMP/, save to $HOME
:0ec:
$HOME/zbackup.not2me.failed

I've added numbers to the recipes to make them easier to talk about.

If (1) matches and succeeds then that is the only action taken.

If (1) doesn't match then (2) is invoked.  If that succeeds then that is
the only action taken.

If (1) doesn't match and the action of (2) fails then (3) is invoked.
If that succeeds then that is the only action taken.

If (1) doesn't match and the action of (2) fails then (3) is invoked.
If (3) fails then (4) is invoked.  If that succeeds then that is the
only action taken.

All that looks to be what you want.  The only quesionable case is if (1)
matches but the action fails.  In that case, (3) is invoked...then (4)
if the action of (3) fails.  That *seems* to be the right thing to do,
but I'm not sure if it is what you intend given your mailbox naming -
the mail would be to you but would be delivered to
zbackup.not2me.failed.

What might make things clearer is putting all the backup recipes into a
clone recipe action, like:

  # do the backup
  :0c
  {
    :0:
    * $ ^TO_$ME
    $HOME/mail/zbackup

    :0E:
    $HOME/TEMP/zbackup.not2me

    :0:
    $HOME/TEMP/zbackup.not2me.failed

    :0:
    $HOME/zbackup.not2me.failed
  }

  # copy continues...

The whole set of backup recipes now has a 'c' flag, so the other recipes
in your .procmailrc get a look-in whatever happens within that nesting
block.

The nesting block itself will complete whenever one of its sub-recipes
has delivered, so there is no need for the 'e' flags (assuming my
interpretation of what you're trying to do is correct!!) on the
error-handling recipes...they should never be reached unless there is an
error.

If I've mis-interpreted and you really want to keep to-you and
not-to-you failed messages in different mailboxes then you could use
something like:

  # do the backup
  :0c
  {
    :0
    * $ ^TO_$ME
    {
        :0:
        $HOME/mail/zbackup

        :0:
        $HOME/TEMP/zbackup.failed

        :0:
        $HOME/zbackup.failed

        # it's all gone horribly wrong!  You might want to do
        # something other than just give up at this point.
        HOST=
    }

    :0:
    $HOME/TEMP/zbackup.not2me

    :0:
    $HOME/TEMP/zbackup.not2me.failed

    :0:
    $HOME/zbackup.not2me.failed
  }

Hope that helps,
Martin
-- 
Martin McCarthy                 /</    http://procmail.non-prophet.org
    `Procmail Companion'        \>\
     Addison Wesley             /</                  PGP key available
_______________________________________________
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>