procmail
[Top] [All Lists]

Re: Saving, using, then deleting a message....

1997-04-16 06:11:00
I'm sorry if the following is offending to you; I've chosen to assume
you are not overtly familiar with Unix shell scripting but not a
complete newbie either (i.e. you are capable of reading the man pages
should the need arise). 

On Tue, 15 Apr 1997 15:38:11 -0700 (PDT),
ariel(_at_)best(_dot_)com (Catherine Hampton) wrote:
I'd like to save a message to a temporary file with all headers intact,
reply to the message with a standard autoreply, append the text
file, send the reply, and then delete the temporary file.  Right now,
I am using an autoreply recipe like this:
<...>
:0
| (formail -bkrt \
    -I"Cc: 
postmaster(_at_)spamsite(_dot_)net,abuse(_at_)upstreamprovider(_dot_)net" \
    -A"X-Loop: noloop(_at_)noloop(_dot_)nlp";\
    cat $HOME/shared/stopjunk) | $SENDMAIL -oi -t

You could write a simple shell script to shuffle things the way you
want them. I'm attaching one below; it is not very general but it will
do what you request. Use like this (assuming you saved the below
script in $HOME/bin/rudereply; also remember to chmod +x it ;^)

:0
| $HOME/bin/rudereply | $SENDMAIL -oi -t

(BTW, I don't think it's too good an idea to use a very
generic-looking X-Loop header. The whole point is it should be unique
beyond any doubt so always using your own e-mail address is a pretty
good idea.)

This works well, but does not preserve the headers of the original
message, which means that the autoreply is not as useful as it might
be to the upstream provider.  

The script here will quote back the entire original message, i.e.
prefix every line in the quoted material with a wedge character. 
This might not be what you want; change the sed snippet to something
that suits your fancy (e.g. sed -e '/^$/q' to include only the header,
or sed -e '/^$/q' -e 's/^/>/' to include the header and quote it. 
man sed for more ideas).

I know there has to be an easy answer to this, but for some reason what
I've tried so far has resulted in either not saving the spam message
at all, or in appending it to an ever-growing file because the program
doesn't properly delete it after the autoreply is sent.

I'd say this is "easy" but it's not an entirely Procmail / Formail
based solution. (But then, what is really.)

Hope this helps,

/* era */

Un-newbie warning: Without comments, this is only a few lines -- to
some it would be more readable +without+ the comments. (For the truly
wizardry, devise a way to do this right from your .procmailrc, without
putting it in an external shell script.)

#!/bin/sh

# Change this to something that suits your setup. 
# Make sure to include the directories for tee, cat, 
# sed, and formail

PATH=/bin:/usr/bin:/usr/local/bin:$HOME/bin

# The message we read on standard input is stored in this file

tmp=/tmp/rudereply.$$

# The temporary storage file will be removed when we finish,
# or when we are interrupted

cleanup="rm $tmp"

trap "$cleanup" 1 2 3 15

# Store the incoming message in $tmp; generate a reply header with 
# formail

tee $tmp | 
    formail -rt -I"Cc: postmaster(_at_)spamsite(_dot_)net" \
        -I"Cc: abuse(_at_)upstreamprovider(_dot_)net" -A"X-Loop: 
ariel(_at_)best(_dot_)com"

# To make this more self-contained, you could embed your angry 
# message here, instead of fetching it from a third file. 
# Something along the following lines (remove leading "# "'s 
# to activate): 
#
# cat <<HERE
# 
# Oooo, I get so angry when I receive stuff like this. 
# Stuff you. 
#
# HERE
#
# # Remove the following line then:

cat $HOME/shared/stopjunk

sed -e 's/^/>/' $tmp

$cleanup

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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