From List-Managers-Owner@GreatCircle.COM Tue Dec 15 09:10:08 1992
Return-Path: <List-Managers-Owner@GreatCircle.COM>
Received: from relay1.UU.NET by cs-mail.bu.edu (5.61+++/SMI-4.0.3)
	id AA15722; Tue, 15 Dec 92 09:10:00 -0500
Received: from mycroft.GreatCircle.COM by relay1.UU.NET with SMTP 
	(5.61/UUNET-internet-primary) id AA25701; Tue, 15 Dec 92 08:56:07 -0500
Received: by mycroft.GreatCircle.COM (4.1/SMI-4.1/Brent-921015)
	id AA24232; Tue, 15 Dec 92 05:39:40 PST
Received: from note2.nsf.gov by mycroft.GreatCircle.COM (4.1/SMI-4.1/Brent-921015)
	id AB24211; Tue, 15 Dec 92 05:38:25 PST
Received: from z.nsf.gov by Note2.nsf.gov id aa26305; 15 Dec 92 8:34 EST
Received: by z.nsf.gov (4.1/SMI-4.1)
	id AA24138; Tue, 15 Dec 92 08:36:27 EST
Message-Id: <9212151336.AA24138@z.nsf.gov>
From: "Michael H. Morse" <mmorse@z.nsf.gov>
Date: Tue, 15 Dec 1992 08:36:27 EST
In-Reply-To: Gene Rackow <rackow@antares.mcs.anl.gov>
       "Re: How to deal with bounces" (Dec 14, 10:09pm)
X-Mailer: Mail User's Shell (7.1.1 5/02/90)
To: Gene Rackow <rackow@antares.mcs.anl.gov>,
        Gess Shankar <gess@knex.gwinnett.com>
Subject: Re: How to deal with bounces
Cc: list-managers@GreatCircle.COM
Sender: List-Managers-Owner@GreatCircle.COM
Precedence: bulk
Status: R


> Something that I've been thinking about adding into majordomo is a
> way to have a list of addreses to check before adding them to the
> list.  If the address is in the bozo list, the request will be
> denied with some message (possibly) until the list maintainer has
> been notified that the bozo address has been corrected in a way suitable
> to both parties.  There are some addresses that keep popping up bad
> and the user keeps sending in subscribe me messages just to stay on the
> list, even though his address, or something, is flakey at best.

Does majordomo check addresses at all before putting them on the list?
I'm pretty sure that Listserv for Unix does not.  I have a little
Perl script (I'm starting to sound like a broken record) that uses
nslookup to at least check that the host name is in the DNS.  That
has almost totally cut out bounces on a non-listserv system I run.
If anyone's interested, I've included it here.  It's not perfect, but
it does most of the job.

--Mike

#!/usr/local/bin/perl
# a script to check a mail address
# returns 0 if OK (far as we know)
# returns 1 if not.

$debug = 0;
$tmp = "/tmp/chkaddr$$";
if ($#ARGV != 0){
   print("usage: check_addr address\n");
   &leave(1);
}
$test = $ARGV[0];

# actually, the first two tests, for 1) embedded spaces and 
# 2) no @ sign will never fail, because download prevents
# spaces, and adds "@nsf.gov" to addresses without an @.

# does it have spaces?
$num_spaces = $test =~ tr/ / /;
if ($num_spaces){
   &leave(1);
}

# does it have an @?
$num_ats = $test =~ tr/\@/\@/;
if ($num_ats != 1){
   &leave(1);
}

# does it have a rhs and lhs?
($lhs,$rhs) = split(/@/,$test);
if (! $lhs || ! $rhs) {     # must have both a rhs and lhs
   &leave(1);
}

# does the rhs have dots?
$num_dots = $rhs =~ tr/././;
if (! $num_dots) {
   &leave(1);
}

# if it has just one dot, does it end with "BITNET"?
if ($num_dots == 1) {
   if ($rhs =~ /\.bitnet$/i) {
      &leave(0);
   }
}

# OK, everything looks pretty good, let's try nslookup
open(LOOK,"|/usr/etc/nslookup > $tmp 2>$tmp") || &leave(1);
print LOOK<<EOM;
$rhs
set querytype=MX
$rhs
EOM
close(LOOK);
open(IN,$tmp) || &leave(1);
while(<IN>){    # look at non-MX query
   if (/^> >/){
      last;
   }
   if (/^Name/) {
      $try = <IN>;
      if ($try =~ /^> >/){
         last;               # shouldn't happen
      }
      if ($try =~ /^Address:\s+\d+\./) { # looks good
         &leave(0);
      }
   }
}
while(<IN>){    # look at MX query
   chop;
   if (/mail exchanger =/){
      &leave(0);
   }
}
&leave(1);


sub leave {
   if($debug){
      print("Exit $_[0].\n");
   }
   if( -e $tmp) {
      unlink($tmp);
   }
   exit ($_[0]);
}

