OK, I didn't look at thousands of messages to get the proper format, and
this will only work for ASCII messages.
For those who haven't tunnelled into my deepest thoughts and figured out why
I want to do this, here's the answer: I have one address
<luomat(_at_)cc344191-a(_dot_)ewndsr1(_dot_)nj(_dot_)home(_dot_)com> that I
never gave out to anyone as a
valid address.... the only place it appears is in the posting address when I
post to Usenet. Therefore, if anyone sends me a message to that address, I
am going to assume that they are a spammer who simply harvested all the email
addresses they could get, or someone else I do not want to hear from.
Here is my recipe:
:0
* ^TOluomat(_at_)cc344191-a\(_dot_)ewndsr1\(_dot_)nj\(_dot_)home\(_dot_)com
{
# note: I want to get rid of some X-Headers which may have been
# added, and the original 'From ' line
HEADERS=`formail -I "X-SpamChecker:" \
-I "X-Forwarded:" \
-I "X-Original-From:" \
-I "From " \
-I "X-Formail-Reply-To:"`
# this is the address I want to tell them failed
ADDRESS=luomat(_at_)cc344191-a(_dot_)ewndsr1(_dot_)nj(_dot_)home(_dot_)com
# a little hack to get the sender's name and IP
SENDERIP=`formail -I"Subject:"|grep '^Received'|head -1|sed 's/.*\
(//g'|tr -d ')'`
# set the time
LOCALTIME="`date`"
:0
|(formail -r -I"From: Mail Delivery Subsystem
<MAILER-DAEMON(_at_)peak(_dot_)org>" \
-I"Return-Path: <MAILER-DAEMON(_at_)peak(_dot_)org>" \
-I"Auto-Submitted: auto-generated (failure)" \
-I"Subject: Returned mail: User unknown" \
;\
echo ""; echo ""; \
echo "The original message was received at ${LOCALTIME} "; \
echo "from ${SENDERIP}"; echo ""; \
echo "----- The following addresses had permanent fatal
errors -----" ;\
echo "<${ADDRESS}>" ;\
echo "" ;\
echo " ----- Transcript of session follows -----" ;\
echo "... while talking to cc344191-a.ewndsr1.nj.home.com.:" ;\
echo ">>> RCPT To:<${ADDRESS}>" ;\
echo "<<< 550 <${ADDRESS}>... User unknown" ;\
echo "550 <${ADDRESS}>... User unknown" ;\
echo ""; echo ""; \
echo " ----- Original message follows -----";\
echo ""; \
echo "${HEADERS}"; \
echo ""; \
echo "") | $SENDMAIL $SENDMAILFLAGS ${REPLYTO}
}
Sure it may break, especially the "SENDERIP" part, but it looks pretty good
to me.... the only real problem is my 'From ' line still shows my name, I
think...
Anyway, it was just a minor exercise....
TjL
ps -- Hebrew started as of 2 July, and ends on 22 August, so
please understand if responses are slow. I am taking a 2
semester class in 8 weeks for 6 credits
--
TjL <luomat(_at_)peak(_dot_)org>
f ` cn rd ths ` my hv lrnd hbrw