- 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 $message = <<__MESSAGE__;
+To: $addr
+From: Archive Administrator <dak\@ftp-master.debian.org>
+Subject: $subject
+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($_);