require 5.002;
use strict;
use POSIX;
-use POSIX qw( sys_stat_h sys_wait_h signal_h );
+use POSIX qw( strftime sys_stat_h sys_wait_h signal_h );
use Net::Ping;
use Net::FTP;
use Socket qw( PF_INET AF_INET SOCK_STREAM );
$junk = @conf::nonus_packages;
$junk = @conf::test_binaries;
$junk = @conf::maintainer_mail;
+$junk = $conf::mail ||= '/usr/sbin/sendmail';
$conf::target = "localhost" if $conf::upload_method eq "copy";
package main;
($main::progname = $0) =~ s,.*/,,;
+my %packages = ();
+
# extract -r and -k args
$main::arg = "";
if (@ARGV == 1 && $ARGV[0] =~ /^-[rk]$/) {
elsif (/^Source:\s*/i) {
chomp( $pkgname = $' );
$pkgname =~ s/\s+$//;
+ $main::packages{$pkgname}++;
}
elsif (/^Files:/i) {
while( <CHANGES> ) {
if ($pgplines < 3) {
msg( "log,mail", "$commands isn't signed with PGP/GnuPG\n" );
+ msg( "mail", "or the uploaded file is broken. Make sure to transfer in binary mode\n" );
+ msg( "mail", "or better yet - use dcut for commands files\n");
goto remove;
}
$main::mail_addr = "";
$main::mail_text = "";
+ %main::packages = ();
$main::mail_subject = $file ? "Processing of $file" : "";
}
# then send out
#
sub finish_mail() {
- local( *MAIL );
debug( "No mail for $main::mail_addr" )
if $main::mail_addr && !$main::mail_text;
my $subject = shift;
my $text = shift;
- debug( "Sending mail to $addr" );
- debug( "executing $conf::mail -s '$subject' -a 'X-Debian: DAK' '$addr'" );
- if (!open( MAIL, "|$conf::mail -s '$subject' -a 'X-Debian: DAK' '$addr'" )) {
- msg( "log", "Could not open pipe to $conf::mail: $!\n" );
- return 0;
+ my $package = keys %main::packages ? join(' ', keys %main::packages) : "";
+
+ use Email::Send;
+
+ unless (defined($Email::Send::Sendmail::SENDMAIL)) {
+ $Email::Send::Sendmail::SENDMAIL = $conf::mail;
+ }
+
+ my $date = sprintf "%s", strftime("%a, %d %b %Y %T %z", (localtime(time)));
+ my $message = <<__MESSAGE__;
+To: $addr
+From: Archive Administrator <dak\@ftp-master.debian.org>
+Subject: $subject
+Date: $date
+X-Debian: DAK
+__MESSAGE__
+
+ if (length $package) {
+ $message .= "X-Debian-Package: $package\n";
+ }
+
+ $message .= "\n$text";
+ $message .= "\nGreetings,\n\n\tYour Debian queue daemon\n";
+
+ my $mail = Email::Send->new;
+ for ( qw[Sendmail SMTP] ) {
+ $mail->mailer($_) and last if $mail->mailer_available($_);
}
- print MAIL $text;
- print MAIL "\nGreetings,\n\n\tYour Debian queue daemon\n";
- if (!close( MAIL )) {
- msg( "log", "$conf::mail failed (exit status ", $? >> 8, ")\n" );
+
+ my $ret = $mail->send($message);
+ if ($ret && $ret !~ /Message sent|success/) {
return 0;
}
+
return 1;
}