procmail
[Top] [All Lists]

Re: autoresponder errors, I want a copy

1997-01-05 07:50:18
At 01:18 AM 1/5/97 -0500, Timothy J Luoma wrote:

Hiya.  This is part of my autoresponder/file-sender

:0
*^Subject: send-ascii *\/[^ ].*
* !^Subject:.Re:
{

      file=$MATCH

      MAILDIR=$MAILSERVER
      
      :0
      * ? test -r $MATCH
       |(formail -rt -I"From: Timothy Luoma <luomat(_at_)peak(_dot_)org>" ; \
        /bin/cat "$file" )|$SENDMAIL -oi -t
      
      :0E
       |(formail -rt -I"From: Timothy Luoma <luomat(_at_)peak(_dot_)org>" \
                    -I"Subject: File not found ($MATCH)"      ; \
        /bin/cat "$PROCDIR/file_not_found" )|$SENDMAIL -oi -t 
}


What I want to do is CC myself on the error message.  IE if the  
file is not found, I want to get the same message they do, so I can  
see what mistakes they are making.

What's the best way to do this?

In the formail command, put:
                -A"Bcc: luomat(_at_)peak(_dot_)org" \
or Cc: instead of Bcc: if you want the recipient to see that you are
doing this.

I'd recommend that for *both* formail commands, you also add:
                -A"X-Loop: luomat(_at_)peak(_dot_)org" \
and then in the conditions at the top, have:
        * !^X-Loop:(_dot_)*luomat(_at_)peak(_dot_)org
to avoid mail loops.  Specifically, the subject
        "send-ascii send-ascii"
will start looping when you send yourself a copy unless you do this.
While it's true that you could instead test at the top:
        * !^From:(_dot_)*luomat(_at_)peak(_dot_)org
that would force you to test from a different account.

Your "* !^Subject:.Re:" test does nothing, since nothing caught by
that test would have made it through the previous one.  Also, not
sure why you set file=$MATCH and then continue using both $file
and $MATCH.

Finally, I'd add "Precedence: bulk" so that other autoresponders
will tend to avoid responding, and I'd use ^FROM_DAEMON to
avoid autoresponding to autoresponders, postmasters, mailing
lists, etc.

Thus, my (untested) recipe would look like the following:

        :0
        *^Subject:[     ]*send-ascii *\/[^ ].*
        * !^FROM_DAEMON
        * !^X-Loop:(_dot_)*luomat(_at_)peak(_dot_)org
        {
        
                file="$MATCH"
        
                MAILDIR=$MAILSERVER
                
                :0
                * ? test -r "$file"
                |(formail -rt -I"From: Timothy Luoma 
<luomat(_at_)peak(_dot_)org>" \
                              -A"Precedence: bulk" \
                              -A"X-Loop: luomat(_at_)peak(_dot_)org" ; \
                  /bin/cat "$file" )|$SENDMAIL -oi -t
                
                :0E
                |(formail -rt -I"From: Timothy Luoma 
<luomat(_at_)peak(_dot_)org>" \
                              -A"Precedence: bulk" \
                              -A"X-Loop: luomat(_at_)peak(_dot_)org" \
                              -A"Bcc: luomat(_at_)peak(_dot_)org" \    
                              -I"Subject: File not found ($file)"       ; \
                  /bin/cat "$PROCDIR/file_not_found" )|$SENDMAIL -oi -t 
        }

There should be a space and a tab inside the [  ] above, but I have
a feeling my mailer may be consuming tabs for lunch.

There's one other thing you ought to do here; at present, you are
allowing anyone access to ANY file on your system to which you have
access.  You probably ought to put all files they can have into some
directory (say, $SAFE) and then make sure $file doesn't contain ".."
and doesn't start with "/".  Then, /bin/cat "$SAFE/$file" in the above.

Cheers,
Stan Ryckman (stanr(_at_)tiac(_dot_)net)