Great Circle Associates Majordomo-Workers
(August 1996)
 

Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: SPLITLIST: version 1.1
From: Stanislav Sinyagin <stas @ isf . ru>
Organization: ISF
Date: Mon, 12 Aug 1996 14:50:47 +0400
To: majordomo-users @ GreatCircle . COM, majordomo-workers @ GreatCircle . COM
Cc: stas @ isf . ru
References: <3209A0AB.2A11@isf.ru> <320AF210.129C@isf.ru> <ufaohkkthwd.fsf@sina.hpc.uh.edu> <320EE291.66B0@isf.ru> <ufa4tm9t362.fsf@sina.hpc.uh.edu>
Reply-to: stas @ isf . ru

I released a slightly modified version of Splitlist.
Now it makes sendmail defer the message if it can't connect to SMTP.
As usual, it's available at http://www.isf.ru/~stas/splitlist/

-- 
Stanislav Sinyagin, Webmaster and System manager
International Science Foundation Moscow office
Phones:        (095) 956-21-55, (095) 956-21-57
Fax:           (095) 956-21-56
WWW:           http://www.isf.ru/~stas
E-mail:        stas@isf.ru

===== splitlist  begin === cut here
#!/usr/local/bin/perl

# splitlist: Split a mailing list into little mail jobs
# Stanislav Sinyagin <stas@isf.ru>
# requires Net::SMTP

# Version: 1.1

# Usage: splitlist -l list


# set our path explicitly
$ENV{'PATH'} = "/bin:/usr/bin:/usr/ucb";

# What shall we use for temporary files?
$tmp = "/tmp/splitlist.$$";

# Before doing anything else tell the world I am splitlist
# The mj_ prefix is reserved for tools that are part of majordomo
proper.
$main'program_name = 'splitlist';


# If the first argument is "@filename", read the real arguments
# from "filename", and shove them onto the ARGV for later processing
# by &Getopts()

if ($ARGV[0] =~ /^@/) {
    $fn = shift(@ARGV);
    $fn =~ s/^@//;
    open(AV, $fn) || die("open(AV, \"$fn\"): $!\nStopped");
    undef($/);  # set input field separator
    $av = <AV>; # read whole file into string
    close(AV);
    @av = split(/\s+/, $av);
    unshift(@ARGV, @av);
    $/ = "\n";
}
    
# Read and execute the .cf file
$cf = $ENV{"MAJORDOMO_CF"} || "/etc/majordomo.cf";
if ($ARGV[0] eq "-C") {
    $cf = $ARGV[1];
    shift(@ARGV); 
    shift(@ARGV); 
}
if (! -r $cf) {
    die("$cf not readable; stopped");
}
eval(`cat $cf`)  || die 'eval of majordomo.cf failed';

chdir($homedir) || die("Can't chdir(\"$homedir\"): $!");
unshift(@INC, $homedir);
require "majordomo.pl";
require "majordomo_version.pl";
require "getopts.pl";
use Net::SMTP;



&Getopts("l:") || die("splitlist: Getopts() failed: $!");

if (! defined($opt_l) ) {
    die("splitlist: must specify '-l list' argument");
}

# smash case for the list name
$opt_l =~ tr/A-Z/a-z/;


# Try to connect

$maxRecpts = 10 unless defined $maxRecpts;
$smtpHost = 'localhost' unless defined $smtpHost;
$smtpOurDomain = 'localhost' unless defined $smtpOurDomain;

# Set errno so that sendmail defers the curent mail if we fail to
connect.
$oldErrno = $!;
$! = 75;
$smtp = Net::SMTP->new($smtpHost);
$smtp->hello($smtpOurDomain);
$! = $oldErrno;

open(IN, "> $tmp") or &abort("splitlist: Can't open $tmp: $!");
while (<STDIN>) {
    print IN $_;
}
close(IN);

open(IN, $tmp) or die("splitlist: Can't open $tmp: $!");
&ParseMailHeader(IN, *HeaderFields);
close(IN);
$sender = &RetMailAddr( *HeaderFields );

$listfile = "$listdir/$opt_l";
open(LIST, $listfile) or die("splitlist: Can't open $listfile: $!");

while( not eof LIST )
{
    $smtp->mail( $sender );
    
    $rcptCount = 0;    
    while( ($rcpt = <LIST>) and $rcptCount < $maxRecpts )
    {
        chop $rcpt;
        next if( $rcpt =~ /^\s*$/ ); #skip blank names

        $smtp->to( $rcpt );
        $rcptCount++;
    }
    
    $smtp->data();
    
    open(IN, $tmp) or
        die("splitlist: Can't open $tmp while sending mail: $!");
    while( $dataline = <IN> )
    {
        $smtp->datasend($dataline);
    }
    close(IN);
    
    $smtp->dataend();
}
        
$smtp->quit();

unlink $tmp;

exit(0);
===== splitlist  end === cut here


References:
Indexed By Date Previous: TLB 0.02a released
From: Jason L Tibbitts III <tibbs@hpc.uh.edu>
Next: Probably should be autosubscribed..... thoughts?
From: "Randall S. Winchester" <rsw@Glue.umd.edu>
Indexed By Thread Previous: Re: NEW! #2: speed up your Majordomo 15 times !
From: Stanislav Sinyagin <stas@isf.ru>
Next: Re: New! - Fast delivery for large lists
From: "Mr. Erich L. Markert" <1e6244@sunams.usma.edu>

Google
 
Search Internet Search www.greatcircle.com