procmail
[Top] [All Lists]

Re: complicated recipes

1996-08-12 16:08:58
    > I am wanting to use procmail for handling some of
    > our emails... what we find is that when a recipe
    > succeeds, it ignores the rest, even if the "cc"
    > line has another recipes details in it....

Yes, procmail processes recipes until the mail is delivered.  It is up
to the recipe author to decide what "delivery" means and when it occurs.

    > what we would like to do is when a recipe succeeds,
    > it should check if any further recipes can also
    > be satisfied (with other specified addresses), and
    > it should succeed happily... 

Just make every delivering recipe have a "c" flag, so each delivery is
not a "final" delivery, and procmail will keep chugging along.

For example:

    # if mail is addressed to addr1, deliver to folder
    :0c
    * ^TO(addr1)
    folder1

    # if mail is also address to me, save for me
    :0c
    * $^TO($LOGNAME)
    mailforme

    # If mail is address to the postmaster (I am one of them)
    :0c
    * ^TO(postmaster)
    postmaster

    ...

and so on.  With the 'c' flags, procmail just "copies" the mail, rather
than doing "final" delivery.

    > however if *none* of the recipes succeed it should forward the
    > email to a specified address.....

    # If the mail was never dropped into a folder, then forward it
    :0
    * LASTFOLDER ?? .
    ! lastresortaddress

If you do not have complicated filtering, then LASTFOLDER should be set
only if mail was delivered to a folder or program.  If you have
complicated filtering, which includes pipes as part of a conditional,
then, you may need to keep explicit track of delivered mail:

    :0
    * ^TO(addr1)
    {  OK=1
       :0c
       folder1
    }

    :0
    * ^TO(addr2)
    { OK=1
      :0c
      folder2
    }

    :0
    * ^TO(postmaster)
    { OK=1
      :0c
      postmaster

    }

    :0
    * $^TO($LOGNAME)
    { OK=1
      :0c
      mailforme
    }

    ...

    :0
    * !OK ?? .
    ! lastresortaddress

    > I hope it is clear as to what I wish to do.  Is this possible with
    > Procmail?? Can anyone help?

I hope my examples make it clear that it is certainly possible to
accomplish what you are asking.

Alan

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