Intelligent autoresponders with procmail

by Edd Dumbill

I get far too much email to deal with, so I came up with a procmail hack that sends my "personal FAQ" to new correspondents -- ensuring they receive it only once.


The first version of this hack is designed to work with the exim mail agent.



SENDER=$1
:0 Whc: autorespond-xml.lock
* ^To.*edd@xml\.com
* !^FROM_DAEMON
* !^FROM_MAILER
* !^X-Loop: edd@xml.com
* !^X-MailScanner-SpamCheck.*
* ? test -f $HOME/.autorespond-xml
* !? grep -qi "$SENDER" $HOME/.autorespond-xml.cache
| (formail -rI"Precedence: junk" \
-A"X-Loop: edd@xml.com" \
-I"From: Edd Dumbill <edd@xml.com>"; \
cat $HOME/.autorespond-xml \
) | $SENDMAIL -oi -t && \
echo $SENDER >>$HOME/.autorespond-xml.cache

In the procmail_pipe entry of exim, ensure the command
looks like this (all one line):


command = "/usr/bin/procmail -a ${sender_address} -d
${local_part}"

I also did another version of this that doesn't require
altering the
exim config, but it does abuse formail in strange and
interesting ways.




:0 Whc: autorespond-xml.lock
* ^To.*edd@xml\.com
* !^FROM_DAEMON
* !^FROM_MAILER
* !^X-Loop: edd@xml.com
* !^X-MailScanner-SpamCheck.*
| formail -rD 200000 $HOME/.autorespond-xml.cache \
-I"Message-ID: $1"

:0 ehc # if sender not in the cache
| (formail -rI"Precedence: junk" \
-A"X-Loop: edd@xml.com" \
-I"From: Edd Dumbill <edd@xml.com>"; \
cat $HOME/.autorespond-xml \
) | $SENDMAIL -oi -t

I adapted one of the recipes from procmailex (5).
The version
requiring the exim change seems cleaner to me, as it doesn't
abuse the
semantics of formail quite so badly. But I'm a novice at
this game.



Anyone got a better solution to the problem? I'd be glad to hear.