procmail
[Top] [All Lists]

Re: Generating an e-mail message under certain conditions

1996-05-15 06:54:05
Brock Rozen asked,

| Assuming all variables are set properly and conditions are met, the
| following recipe below will generate an e-mail message containing (almost)
| nothing in it (except the basic headers, no subject) whenever the $HELPLOG
| file exists. If it doesn't exist than it will be created by touch and the
| unwanted e-mail message isn't sent.
| 
| Can anybody please enlighten me as to why this e-mail message is being
| generated and how I can prevent it from being generated? Thanks.

What unwanted email message are you talking about?  The headers recorded in
$HELPLOG by the last recipe?  The autoreply sent out by the first recipe?
Who receives the unwanted message?

| :0 hc
|   * !^FROM_DAEMON
|   * !^X-Loop: $COMSAT

You're missing the $ modifier there to make procmail expand variables inside
a condition, so your loop detection is not going to work.

|   * ^Subject: *(send|get) Help
|   | ($FORMAILZ -I 'From ' \
|       -I"From: $FROMZ" -r \
|       -A"X-Loop: $COMSAT" \
|       -A"X-Auto-Request: Help" \
|       -A"Precedence: junk" \
|       -I"Subject: Information and Help on Brock Rozen's Auto-Reply System";\
|     cat $PMDIR/text.help) | $SENDMAIL -oi -t

formail -r will automatically strip out the From_ line, so "-I 'From '" is
unncessary.

|   :0Ac
|   * !? test -f $HELPLOG
|   | touch $HELPLOG

Why do you need to do that?  Does your shell require that the helplog already
exist because you have the ">>" redirector in the next recipe?

One problem there is that, if the file does not yet exist and procmail
invokes touch, procmail will complain that the action line is not accepting
the input.  You should use the `i' flag on that recipe so that procmail won't
care whether the input is read or not (and it wouldn't hurt to add `h' or
`b', whichever part of the incoming letter is likely to be shorter, to cut
down on the text that procmail tries to feed to touch).

|   :0A:
|       | ( $FORMAILZ -XFrom: -XDate: -XSubject: -XRequested-Via: ; echo ) >> 
$HELPLOG

If you feed only the head to formail, -k will keep the blank line that
follows the head [formail will never see the body proper], so you will save
on two counts: procmail will feed less text to formail and you won't need to
include "; echo" or the parentheses:

   :0Ah:
   | $FORMAILZ -k -XFrom: -XDate: -XSubject: -XRequest-Via: >> $HELPLOG

I'm still not sure exactly what you're describing, Brock, but perhaps what
I've said here will help.

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