procmail
[Top] [All Lists]

Re: Newbie vacation query

1996-09-19 12:26:48
In a previous reply, I had made an assumption that there was no attempt
to save mail in the procmail recipe, because the recipe was being
invoked by a .forward file, which was *already* saving the mail:

    >     > .forward contents
    >     > \temp1, "| /usr/lbin/procmail"

If, however, the user is relying on procmail to *also* save mail by
default (ie: falling off the end of the recipe), the most of my analysis
is wrong, since it was based on allowing mail not being replied to be
dropped.  Thanks to David Tamkin for pointing this out.

This advice still holds:

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

    >     > 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
    >     > 
    >     > .procmailrc contents
    >     > SHELL=/bin/ksh
    >     > PATH=$PATH:/usr/lbin

The recipe below is correct, if you are running formail only for its
return code, and not to actually drop the mail.  Using the "c" causes
formail to be run, and its return code to be used for subsequent use by
"a" and "e" flag recipes, but it will not affect the "delivered" state
of the mail buffer.

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

The above advice is also correct; if you do repeated tests, you should
make sure the file "vacation.cache" is empty to verify the formail
failure case, and make sure it isn't empty to verify the formail success
case. 

This recipe then is okay in combination with the one 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

However, as David Tamkin points out, both recipes can be combined, and
using the improvements from my previous mail, might look like:

    NONALFA="[^0-9a-zA-Z]"

    :0 hc:vacation.lock
    * !^FROM_DAEMON
    * !^X-Loop: temp1(_at_)cronos(_dot_)com
    * ! ? formail -rD 8192 vacation.cache
    * $!^((Resent-|Apparently-)?(From|Sender):|From 
)(.*$NONALFA)?$LOGNAME($NONALFA|\$)
    {
        # Use regexp operator "\/" to mark the beginning of MATCH to get
        # the subject text, instead of a formail invocation.
        :0
        * ^Subject: *\/.*
        { SUBJ=`echo $MATCH | sed -e 's/"/\'/g'` }

        :0 hc
        | (formail -rt  -I"From: $LOGNAME"                      \
                        -I"Subject: Your mail on \"$SUBJ\""     \
                        -I"Precedence: junk"                    \
                        -I"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
    }
    # Mail will get delivered by default.

The only disadvantage to combining the recipes is that the lockfile
"vacation.lock" is held for a longer time than with the two separate
recipes. 

Also, if "formail" fails for any reason, an empty or a non-header file
may get fed to sendmail.  This is why I prefer to replace the headers
and body, and the deliver the mail, with separate filtering recipes.
___________________________________________________________
Alan Stebbens <aks(_at_)sgi(_dot_)com>      http://reality.sgi.com/aks

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