procmail
[Top] [All Lists]

Re: Examples website?

2000-11-01 13:26:38
At 08:35 2000-11-01 -0800, Datona Communications wrote:
Does anyone out there know of a website which has example on how to configure procmail?

There are several FAQ pages. While finishing this reply, I see you've just recieved posts pointing you in that direction.

I am actually looking for an example which will show me how to pull a variable from an email and pass it off to a perl script or add the variable to a text file. The example variable would be in the body of the email and would be something like:

bla bla bla:  123456

:0
* ^any_other_header_you_might_flag_on:.*content
{
        :0Bi:
        * ^bla bla bla:[        ]*\/[^  ].*
        |perl /path/some_script.pl $MATCH
}


The above is untested, but is something similar to what you'd use. If *ALL* emails are expected to have this criteria, go ahead and eliminate the outer condition and braces, otherwise, modify that condition to catch the message based on a subject, or TO: or whatever makes these messages outwardly different than all the other mail arriving at this account.

The flags on the inner recipe say "B" - egrep the BODY, 'i' - ignore write errors (with the pipe, the perl script doesn't need to read the message, but this is how you'd invoke it), ':' use a lockfile (optional, if the perl script is outputting to another file, you probablty don't want two copies of it running simultaniously).

Match on a line ^ beginning with "bla bla bla:", followed by any number of tabs or spaces (the brackets contain one tab and one space), then \/ start the match condition, and match anything not including a tab or space (the caret ^ in the brackets here means inversion, not "start of line", as it does elsewhere). The match is placed in the variable $MATCH.

We then pipe the message to your perl script, passing the $MATCH text. Your script can elect to use or ignore the mail message waiting for it on STDIN.


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