#!/usr/bin/perl ## This script written by John Hall. Scans $logdir directory for files created ## by the companion script, cvs_loginfo_batchemail.pl and sends e-mails ## appropriately. ## john@optionexist.co.uk ## (c) 2001 John Hall, OptionExist Ltd. use Net::SMTP; # directory where log files are created by cvs_loginfo_batchemail.pl $logDir = 'e:/cvs-mail'; # smtp server $smtpServer = 'optex1.optex.local'; # from address $cvsFrom = 'cvs@optex.local'; # message header $header = 'This is a summary of files recently committed to the CVS Repository'; opendir DIR, $logDir || die "Directory $logDir: $!"; @files = readdir DIR; close DIR; foreach (@files) { if (!/^\./) { my $filename = $_; my $subject_hint; ($subject_hint = $filename) =~ s/-cvs@.*//; open DATA, "$logDir/$filename" || die "File $logdir/$filename: $!"; if (! defined($smtp)) { $smtp = Net::SMTP->new($smtpServer); } $smtp->mail($cvsFrom); $smtp->to($_); $smtp->data(); $smtp->datasend("From: cvs <$cvsFrom>\n"); $smtp->datasend("To: <$_>\n"); $smtp->datasend("Subject: CVS Commits ($subject_hint)\n\n"); $smtp->datasend("$header\n"); $smtp->datasend(); $smtp->dataend(); close DATA; unlink "$logDir/$_"; } } $smtp->quit if (defined($smtp));