Hi,
I am relatively new to procmail. That's why I am not sure if what I
constructed is stable, reliable and free of "tricky" stuff. I really would
appreciate any comments of you experts.
This is what I want to do:
In the rc.files I only want one recipe that takes care for all tasks for all
autoresponders. So when I add an autoresponder, the only thing I need to do
is add the name to a file.
The autoresponder recipe should perform the following tasks:
- check if incoming mail is addressed to autoresponder
- if autoresponder:
* log email address and time in file named after the autoresponder
* store email message in mailbox named after the autoresponder
* send return message to sender
example:
abc(_at_)xyz(_dot_)com sends mail to autoresponder
test-1(_at_)mycompany(_dot_)com(_dot_)
Then email address abc(_at_)xyz(_dot_)com and the time (in seconds since Jan1,
1970)
are loged in a file test-1.log (perl program maildirect.pl takes care for
this)
Then the sent mail from abc(_at_)xyz(_dot_)com is put in mailbox test-1 and
autoresponder recipe sends response mail
(file: .test-1.mycopmany.com.response) to abc(_at_)xyz(_dot_)com
I have coocked up the following autoresponder recipe that performs the above
mentioned tasks:
-------- .rc.autoresponders --- begin --------
RESPONSE_FILE_DIR=$MAILDIR/response.files
LOGDIR=$MAILDIR/autoresponder.logs
LOGPROG=maildirect.pl
INCLUDERC=.rc.autoresponder.names
:0
* $RECIP ?? ^^($AR)@$DOMAIN
* $RECIP ?? ^^\/[-\(_dot_)0-9a-zA-Z]+(_at_)$DOMAIN
{
TOMAIL=$MATCH
:0
* TOMAIL ?? ^^\/[-\.0-9a-zA-Z]+
{
TOMAIL=$MATCH
:0c
$TOMAIL
:0ci
|(formail -r -x "To:")| $MAILDIR/$LOGPROG $LOGDIR/$TOMAIL.log
:0h
* !^FROM_DAEMON
* !^X-Loop: $TOMAIL(_at_)$DOMAIN
|(formail -rtk -A"X-Loop: $TOMAIL(_at_)$DOMAIN" -A"Precedence: junk"; \
cat $RESPONSE_FILE_DIR/.$TOMAIL.$DOMAIN.response ) | $SENDMAIL -f$RECIP -t
:0
/dev/null
}
}
-------- .rc.autoresponders --- end --------
The names of the "active" autoresponders are stored in the file
.rc.autoresponder.names
-------- .rc.autoresponder.names --- begin --------
AR=\
test-1|\
test.2|\
test3
-------- .rc.autoresponder.names --- end --------
A couple of my questions:
Is the above approach the right one or is there a better way to do it?
Is my recipe solid and reliable even when receiving massive email?
Do I really need the perl script to log the email address and time. Is there
a better way to do this?
Any help and/or comments are welcome and much appreciated.
Thanks a lot for your kind assistance!
Ton
PS
$RECIP is initialized in .procmailrc like: RECIP=$1
$DOMAIN is initialized in .procmailrc like: DOMAIN=mycompany.com