procmail
[Top] [All Lists]

Re: Newbie vacation query

1996-09-19 10:32:47
When trying to discover what is happening in a procmail recipe, use the
following statements at the top of your .procmailrc file:

    VERBOSE=yes LOGABSTRACT=all LOGFILE=log

and, after running some testmail through your .procmailrc, examine the
"log" file.

I also have some comments on the recipes below, interspersed for
convenient reference.

    > Procmail newbie question.
    > 
    > Replies to fdpx(_at_)cronos(_dot_)com until I straighten out the rest of 
the
    > mail system.....
    > 
    > I am trying to install a program to do the same as vacation.
    > Vacation versions looked naff, procmail looked more promising.
    > (And less overhead than using perl)
    > 
    > Using PTX 2.1.8 on a Sequent.
    > 
    > On building I get some 'Arguement incompatible with prototype'
    >  as well as the normal loop warning, is this significant ?
    > 
    > Using the vacation example from the manual, with a little tweaking
    > to save time, I get an a vacation.cache with appropriate entries,
    > but no reply message.
    > 
    > I have tested out the command with the second rule, and that works okay.
    > Its as though the second rule is never run.
    > 
    > ptx uname stuff:
    > 3.2.0 V2.1.8 i386
    > 
    > .forward contents
    > \temp1, "| /usr/lbin/procmail"
    > 
    > .procmailrc contents
    > SHELL=/bin/ksh
    > PATH=$PATH:/usr/lbin
    > 
    > :O Whc: vacation.lock
    > * !^FROM_DAEMON
    > * !^X-Loop: temp1(_at_)cronos(_dot_)com
    > | formail -rD 8192 vacation.cache

The formail will throw away mail from the same sender.  So, of course
you will see nothing from the procmail if you have *ever* received mail
from the reply address in your test mail.  To be sure that formail
doesn't throw away the test mail, make sure that "vacation.cache" is
nonexistant or empty:

I would rewrite the recipe like this:

    :0 Wh:vacation.lock
    * !^FROM_DAEMON
    | formail -rD 8192 vacation.cache

And, run the test this way:

    cat /dev/null >vacation.cache
    procmail -m .procmailrc <testmail

Also, why were you using "c" above?  Do you want to do further
processing on mail that you aren't responding to?  From the recipe
below, it doesn't look like it.

If you don't want to do vacation responses on looped mail, the place the
"X-Loop" on the recipe below, not the formail above.

    > :O ehc
    > | (formail -rA"Precedence: junk" \
    >    -A"X-Loop: temp1(_at_)cronos(_dot_)com" ;\
    >   echo "I received your mail " ; \
    >   echo "but won't be able to read it " ;\
    >   echo " Till I sort the mail out" ; \
    >   echo "--- " ; cat $HOME/.signature \
    >   ) | $SENDMAIL -oi -t

The "e" is not necessary if you omit the "c" in the previous recipe,
since, if "formail" succeeds then processing stops.

You can write this more elegantly (IMHO) as:

    NONALFA="[^0-9a-zA-Z]"
    :0 h
    * ^!X-Loop: *temp1(_at_)cronos(_dot_)com
    * !^MAILER_DAEMON
    * $!^((Resent-|Apparently-)?(From|Sender):|From 
)(.*$NONALFA)?$LOGNAME($NONALFA|\$)
    {
        # Get the subject
        SUBJ=`formail -xSubject: | sed -e 's/"/\'/g'`

        # Replace the headers with a reply; NB: always use "-rt"
        :0 fhw
        | formail -rt   -I"From: $LOGNAME" \
                        -I"Subject: Your mail on \"$SUBJ\"" \
                        -I"Precedence: junk" \
                        -I"X-Loop: temp1(_at_)cronos(_dot_)com"

        # Replace the body (and ignore the current body)
        :0 afbi
        | echo "I received your mail but won't be able to read it" ; \
          echo "until I return from vacation and sort my mail out" 

        # Tack on the signature file (if it exists)
        :0 afbw
        * ? test -r $HOME/.signature
        | cat - ; echo "--- " ; cat $HOME/.signature

        # Now send the composed reply
        :0 aw
        ! -t
    }
    # Any mail which gets past here is mailer-daemon or 

Note:

* It won't reply to itself (X-Loop);

* It won't reply to a mailer

* It won't reply to yourself (mail you send to yourself, either directly
  or indirectly, through a list).

* If any part of the reply generation fails, it won't send it -- no
  bogus mail goes out.  See the use of "a" and "w" in the recipes.

This recipe is longer, but illustrates a flexible, customizable method
of reply generation which will act correctly under most conditions.

    > procmail -v output:
    > procmail v3.10 1994/10/31 written and created by Stephen R. van den Berg
    >                           
berg(_at_)pool(_dot_)informatik(_dot_)rwth-aachen(_dot_)de
    > 
    > Submit questions/answers to the procmail-related mailinglist by sending 
to:
    >   procmail(_at_)informatik(_dot_)rwth-aachen(_dot_)de
    > 
    > And of course, subscription and information requests for this list to:
    >   procmail-request(_at_)informatik(_dot_)rwth-aachen(_dot_)de
    > 
    > Locking strategies:       dotlocking, fcntl(), lockf()
    > Default rcfile:           $HOME/.procmailrc
    > System mailbox:           /usr/mail/$LOGNAME

<Prev in Thread] Current Thread [Next in Thread>