procmail
[Top] [All Lists]

Re:multi auto-reply

2000-11-16 11:18:33
At 9:50 AM -0500 11/16/00, Herman Li is rumored to have typed:

Sounds simply, but now I am baffelled even after reading the manual hehe! :-)

   Well, ok, I can't fault you for that. Sometimes my eyes glaze over reading
man pages, too...

Can someone give me an idea on this clone copy thing?

   Sure. Let's start with something simple. Here's an example of a delivery
recipe which delivers to a text file without using a local lockfile:

:0
* ^TOinfo(_at_)mydomain(_dot_)com
/home/info/inbound.txt

   Now here's the same example using a local lockfile who's name is
determined by procmail:

:0 :
* ^TOinfo(_at_)mydomain(_dot_)com
/home/info/inbound.txt

   See the difference? There's a terminating colon after the recipe header.
If we want to manually name the lockfile, we'd do this:

:0 : /home/info/inbound.lock
* ^TOinfo(_at_)mydomain(_dot_)com
/home/info/inbound.txt

   Notice we're changing the header commands to procmail, telling it that
whatever the condition or final action, we want to do something in the case
of the _entire_ recipe, win, lose, or draw.

   Now let's say we want to place the same message in two different text
files - since when we have a delivery recipe, the procesing will stop
completely, this will NOT work:

:0
* ^TOinfo(_at_)mydomain(_dot_)com
/home/info/inbound.txt

:0
* ^TOinfo(_at_)mydomain(_dot_)com
/home/info/inbound_copy.txt

   ...since the first recipe delivers, processing stops, and procmail never
even _sees_ the second recipe! The easiest way around it is to create a
clone, or copy, of the message, and deliver _that_ in the first recipe. If we
do that, the "real" mail is still hanging around _undelivered,_ so processing
_won't_ stop:

:0 c
* ^TOinfo(_at_)mydomain(_dot_)com
/home/info/inbound.txt

:0
* ^TOinfo(_at_)mydomain(_dot_)com
/home/info/inbound_copy.txt

   Note we've changed header information again, adding a "c" to tell
procmail, "Hey, create a clone of the message for this recipe only - and by
the way, dump it after this recipe whether you deliver the clone or not."
Cool, huh?

   Of course, we should probably use lockfiles when we're writing to disk
files, since we wouldn't want two messages to get mixed up in the possible
event that two emails come in at roughly the same time and two different
procmail processes are working at the same time; so we might use something
like:

:0 c : /home/info/inbound.lock
* ^TOinfo(_at_)mydomain(_dot_)com
/home/info/inbound.txt

:0 : /home/info/inbound_copy.lock
* ^TOinfo(_at_)mydomain(_dot_)com
/home/info/inbound_copy.txt

   If you check out the man pages, you'll see there are a whole BUNCH of
modifiers we can add to the recipe header to do LOTS of cool stuff! And we
can also "bracket" recipies, so we might write that one a little differently
and possibly more efficiently:

:0 : /home/info/inbound.lock
* ^TO info(_at_)mydomain(_dot_)com
{
   :0 c
   /home/info/inbound.txt

   :0
   /home/info/inbound_copy.txt

}

   It shouldn't be difficult to extropolate this information to your
situation, where you want to do two or more things with a single email
message sent to the autoresponder.

         Charlie


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