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:
|
|