procmail
[Top] [All Lists]

Re: Stupid Newbie Questions

2000-09-04 14:53:55
At 13:50 2000-09-04 -0700, Ben Ocean wrote:
Hi;
Procmail came recommended for a simple autoresponder script. I've installed it, now how do I write the auto-response? Email comes to 3 different URLs at

Minour terminology issue: email comes to email addresses. URLs are how links are idenfified on webpages.

web site (the other two are pointed here):

via sendmail aliases, we must assume?

can I use this one script to accommodate all three?

Yes, though your ability to positively track them if say, you get messages which are sent via BCC (intended recipient not identified in a cleartext header), or sent to more than one of the individual addresses.

Can I have different messages sent in response to messages sent to different users (e.g., bill@; mike@; etc.)?

Yes, but BCC and multiple-addressee issues will still exist (if bill AND mike are both recipients on a single message, what do you do -- conventional scripting will see the FIRST check twice - or if you do a copy rule, will see BOTH twice).

Certainly, in your typical web-originated message, you won't generally have this problem, but it may crop up.


Caveat: the below recipe is not operationally tested. Use 'man procmail', man 'procmailrc', 'man procmailex', 'man formail', and 'man sendmail' to figure out what the flags and switches are for. manpages are useful for that...


#define MAILDIR (where mail is stored into mailboxes - NOT the spool)
MAILDIR=$HOME/Mail

# define SENDMAIL (path to sendmail executable on your system, or just
# the sendmail prog if you have it in the defined path)
SENDMAIL=/usr/bin/sendmail

# define FORMAIL (path to formail executable - part of the procmail
# distribution)
FORMAIL=/usr/bin/formail

# define AUTOREPLY directory (where you dump auto reply texts)
AUTOREPLY=$HOME/.procmail/auto-reply

:0
* ^TOmike(_at_)yourdomain\(_dot_)tld
{
        # If you were so inclined, you could forward a copy of this message
        # to someone else.  This bloke will get daemon messages as well.
        # Danger Will Robinson: autoreplies from this mailbox would be bad,
        # as would this address being ANOTHER alias for the same mailbox
        # that this autoreply is being handled from - if you've got to do
        # that, doing a 'c' flag on the above rule makes more sense, or
        # doing a filter rule that adds an X-loop before forwarding a copy.
#       :0c
#       !fwdaddr(_at_)otherdomain(_dot_)tld

        # File a copy of the original incoming message.
# *MUST* use the c (copy) flag, or the autoreply will never take place.
        :0c:
        $MAILDIR/mike.gz

        # Autoreply some static text to the sender.
        # If it is looped or from the mailer daemon, do nothing more.
        :0
        * !^FROM_DAEMON
        * !^X-Loop: mike(_at_)yourdomain\(_dot_)tld
        | ( $FORMAIL -rt -A "X-Loop: mike(_at_)yourdomain(_dot_)tld" \
                -I "From: mike(_at_)yourdomain(_dot_)tld (autoreply mailbot)" ;\
                cat $AUTOREPLY/mike.msg ) | $SENDMAIL -t

        # if it was a daemon or looped message (fell through to here)
        # toss it...
        :0
        /dev/null
}


create ~/.procmail and ~/.procmail/auto-reply
create ~/Mail (if necessary)
put your auto-reply text in ~/.procmail/auto-reply/mike.msg
edit this script as necessary
save this script as ~/.procmailrc

You can copy and edit the whole mike block (but not the variable definitions above it), for each alias you're using on the account. Be sure to tweak all the named occurrences. You MIGHT rather use a generic 'hosted account' for the X-Loop identifiers (for example, "X-Loop: autoreply(_at_)yourdomain(_dot_)tld").

edit .forward as necessary (if procmail is invoked by your sendmail config as the LDA - local delivery agent, then you don't need - or want - a .forward to invoke procmail).

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