🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by John A. Palkovic Tue, 22 Oct 1991 16:30
Filter for email bounce messages
#3988
Author: John A. Palkovic
Date: Tue, 22 Oct 1991 16:30
171 lines
5655 bytes
This is a filter for email bounces which I hacked together over the
summer.  It uses an awk(1) script to do the work of removing the text
and subject of the bounced message. I had been using a script that
Andy Poling wrote, but I did not like the way it nuked the whitespace
on continuation lines. The awk script has to make some assumptions
about the structure of the bounced message header. It works with IDA
sendmail 5.65c.

If your awk complains about the script I would like to know about it.
I have run this under SunOS 4.1 /bin/awk, which is pretty "old."

Thanks to Andy Poling for writing the original script and for
suggesting a modification in this one.

-John


#!/bin/sh
# This is a shell archive (shar 3.46)
# made 10/22/1991 15:35 UTC by john@phc.org
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   1266 -rw-r--r-- README
#    609 -rwxr-xr-x bounce.awk
#    819 -rwxr-xr-x polite
#
# ============= README ==============
if test -f 'README' -a X"$1" != X"-c"; then
	echo 'x - skipping README (File already exists)'
else
echo 'x - extracting README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'README' &&
This is a filter I use with sendmail to avoid revealing the contents
and sunjects of bounced email messages to the postmaster's eyes. It
was inspired by a shell script written by Andy Poling
(andy@gollum.hcf.jhu.edu).
X
To install, you need to
X
1) Unshar the package.
X
2) Save the scripts into some directory. Edit the shell script and
change 'awkfile' so it can find the awk script, bounce.awk.
X
3) Edit your sendmail.cf. If you don't like the idea of doing this,
then don't bother trying to install this package. You need to change
the definition of the 'P' option to point at an alias that pipes the
bounced message into the script. In my sendmail.cf, I have
X
X   #				postmaster copy of returned messages
X   OPbounced
X
then in my sendmail aliases file (usually /etc/aliases) I have
X
X   # This script strips body and subject from the message before sending it
X   # to the postmaster
X   bounced: "|/usr/local/etc/polite"
X
If necessary, change your postmaster alias to point at a human who
gets the bounce messages.
X
You may need to refreeze your sendmail.cf file after you edit it, you
definitely need to rebuild the aliases database (sendmail -bi). Kill
and restart your sendmail daemon. Make sure the script is executable.
X
John Palkovic Oct 22, 1991
john@phc.org
SHAR_EOF
chmod 0644 README ||
echo 'restore of README failed'
Wc_c="`wc -c < 'README'`"
test 1266 -eq "$Wc_c" ||
	echo 'README: original size 1266, current size' "$Wc_c"
fi
# ============= bounce.awk ==============
if test -f 'bounce.awk' -a X"$1" != X"-c"; then
	echo 'x - skipping bounce.awk (File already exists)'
else
echo 'x - extracting bounce.awk (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bounce.awk' &&
#
# 9/19/91 john@phc.org
# If you have ideas on how to improve this, please let me know.
#
BEGIN{ inbody = 0 ; sawfoo = 0}
X
inbody == 0 && /^$/ {	# End of real header
X	print
X	inbody = 1
X	next
X	}
inbody == 0 && $0 !~ /^$/ {print}
X
inbody == 1 && $0 ~ /----- Unsent message follows -----/ {
X	print "   ----- Unsent message headers -----"
X	sawfoo = 1
X	next
X	}
inbody == 1 && sawfoo == 0 {print;next}
sawfoo == 1 {
X	if ( $1 == "Subject:" ) {
X		print $1, "[removed for privacy]"
X		next
X		}
X	else
X		print
X	}    
sawfoo == 1 && /^$/ {	# End of failed header
X	printf "\t[message body removed for privacy]\n"
X	exit
X	}
SHAR_EOF
chmod 0755 bounce.awk ||
echo 'restore of bounce.awk failed'
Wc_c="`wc -c < 'bounce.awk'`"
test 609 -eq "$Wc_c" ||
	echo 'bounce.awk: original size 609, current size' "$Wc_c"
fi
# ============= polite ==============
if test -f 'polite' -a X"$1" != X"-c"; then
	echo 'x - skipping polite (File already exists)'
else
echo 'x - extracting polite (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'polite' &&
#!/bin/sh
PATH=/usr/bin:/usr/ucb:/usr/etc:/usr/local/bin
export PATH
#  This is a filter for error messages to avoid disclosing
#  private mail to the postmaster
#
#  What it does is:
#  * remove the Subject: line from the headers of the bounced mail
#  * remove the message body
# Inspired by a script written by:
# Andy Poling	5-29-90
# (andy@gollum.hcf.jhu.edu)
#
# Changed to use an awk(1) script I wrote.  It will no longer nuke
# whitespace at the beginning of continuation lines.
# John Palkovic 10-14-91 (john@warped.phc.org)
#
# Edit this to point at the installed awk script:
awkfile=/usr/local/etc/bounce.awk
#
(
cat <<WooF
XFrom: MAILER-DAEMON
To: postmaster
Subject: Bounced mail
X
================================= FAILED MAIL =============================
WooF
#
awk -f $awkfile ) | mail postmaster
Xexit 0
SHAR_EOF
chmod 0755 polite ||
echo 'restore of polite failed'
Wc_c="`wc -c < 'polite'`"
test 819 -eq "$Wc_c" ||
	echo 'polite: original size 819, current size' "$Wc_c"
fi
exit 0
-- 
palkovic@mp.cs.niu.edu || john@warped.phc.org
I joined the League for Programming Freedom
 -- write to league@prep.ai.mit.edu
Re: Filter for email bounce messages
#3989
Author: Wolfgang S. Rupprecht
Date: Wed, 23 Oct 1991 18:22
40 lines
1574 bytes
palkovic@mp.cs.niu.edu (John A. Palkovic) writes:
>This is a filter for email bounces which I hacked together over the
>summer.  It uses an awk(1) script to do the work of removing the text
>and subject of the bounced message. 

Why bother?  Just have IDA not send the message back.  Its a one line
change.

diff -c savemail.c.~1~ savemail.c
*** savemail.c.~1~	Mon Jun 24 12:23:02 1991
--- savemail.c	Fri Oct 11 00:31:50 1991
***************
*** 244,252 ****
  					break;
  				}
  			}
  			if (returntosender(e->e_message != NULL ? e->e_message :
  					   "Unable to deliver mail",
! 					   q, TRUE) == 0)
  			{
  				state = ESM_DONE;
  				break;
--- 244,255 ----
  					break;
  				}
  			}
+ 
+ #define BOUNCE_WHOLE_MSG FALSE /* Was TRUE.  DONT send back whole msg. -wsr */
+ 
  			if (returntosender(e->e_message != NULL ? e->e_message :
  					   "Unable to deliver mail",
! 					   q, BOUNCE_WHOLE_MSG) == 0) 
  			{
  				state = ESM_DONE;
  				break;


-- 
Wolfgang Rupprecht    wolfgang@wsrcc.com (or) uunet!wsrcc!wolfgang
Snail Mail Address:   Box 6524, Alexandria, VA 22306-0524
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads