procmail
[Top] [All Lists]

Re: [newbie] execute script on new mail

2000-07-30 11:53:07
At 19:29 2000-07-30 +0200, Vincent De Baere - narrowmargin wrote:

Since i am not really familiar with programming on the Linux-OS, i would
really appreciate hints on how to do it (including tips regarding which
scripting language is most convenient for doing it... etc.)

Well, how you write the script or program to do your SQL stuff is entirely your problem -- that is outside of the domain of procmail. Perl is likely to be your best bet, and there are forums for finding help on that (check usenet).

You'll also need to clarify whether the SQL has to be performed BEFORE the forward, and whether the forward is in fact a real forward (message redirected to another mail account), or if you're talking about storing the message in the SQL database somehow. Do *ALL* messages get processed in this fashion, or just ones with certain criteria?

In the most simplistic terms though:

:0
* ^Subject:.*some key phrase
{
        :0ci
        | some_perl_script

        :0
        !forwardaddress
}

The ^subject thing would be removed if this is supposed to be for ALL messages, and otherwise that line (or lines) would have whatever constructs are necessary to match this message as something to operate on (for instance, you may want to put mailer-daemon checks in, so that bounces don't cause grief).

The first sub-rule pipes a copy of the message into a perl script. Now, whether that perl script actually USES the message or not doesn't matter -- it gets called, and if it needs it, the message (headers and body and all) is sitting on STDIN. Flags can be specified to provide just the headers or body if desired. After that, the message is forwarded to the forwarding address (the ! is the forward construct).

The specifics are up to you, as is the SQL scripting.

---
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

 Sean B. Straw / Professional Software Engineering
 Post Box 2395 / San Rafael, CA  94912-2395


_______________________________________________
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>