Advanced parsing with procmail
October 10, 2005 8:40 AM   Subscribe

Procmail text parsing. Might you be able to help?

I'm attempting to set up an autoreply server where if you send mail in the form of, it will reply back to your@email.address. I've been playing around with regex's to parse the text, but it doesnt' seem to be clicking and I'm wondering if I'm missing something fundamental.
posted by VulcanMike to Technology (9 answers total)
Procmail's pattern-matching support is archaic. It's easy enough to use extended-egrep regexes in rule conditions, but not at all easy to use parts of the match results in the rule actions. Have you read section 6 and subsection 7.14 of the Procmail Tips page?
posted by nicwolff at 9:57 AM on October 10, 2005

Whenever I did that sort of thing in procmail, I'd let procmail handle the match, and have the action be a pipe to a program (usually in Perl, but that's just because I'd use Perl for that sort of thing, YMMV) that would take the whole message on stdin and extract the return address and send out the response message itself.
posted by mendel at 10:58 AM on October 10, 2005

Maildrop is the modern replacement for Procmail.
posted by Sharcho at 1:22 PM on October 10, 2005

Ooh. Gonna check out Maildrop. I'll look into piping as well, and thanks for the pointer, nicwolff -- been digesting the tips as best as possible for a few days!
posted by VulcanMike at 1:32 PM on October 10, 2005

here's some chunks from my procmail that do similar things. first one sends an automated response from a file, second sends the output from a pipe. note that they just reply straight back, which is what you want by the sounds of things.

:0 h
* ^From.*(@(xxxx\.com|yyyyy\.com)|aaaa@|bbb.*ccccc)
* !^X-Loop:
| (formail -rtI"Precedence: junk"\
cat /home/andrew/.xxxx.msg) | $SENDMAIL -t

:0 h
* ^To.*
* !^X-Loop:
| (formail -rtI"Precedence: junk"\
echo "hello world") | $SENDMAIL -t
posted by andrew cooke at 4:13 PM on October 10, 2005

oh, well after editing out "sensitive information" they're pretty much identical. but i hope you get the idea.
posted by andrew cooke at 4:14 PM on October 10, 2005

Thanks andrew! My biggest challenge is really in getting:

from the TO headre chopped down into...


to form the reply address
posted by VulcanMike at 10:06 PM on October 11, 2005

right, but you don't need it (unless i've misunderstood). you can just reply to sender, hence the examples above.
posted by andrew cooke at 10:24 AM on October 13, 2005

Yample seems like another interesting alternative
posted by Sharcho at 3:40 PM on January 5, 2006

« Older Migraine Recovery Filter: Wha...   |  What is the best place to look... Newer »
This thread is closed to new comments.