- debug( "Sending mail to $addr" );
- debug( "executing $conf::mail -s '$subject' '$addr'" );
- if (!open( MAIL, "|$conf::mail -s '$subject' '$addr'" )) {
- msg( "log", "Could not open pipe to $conf::mail: $!\n" );
- return 0;
- }
- 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" );
- return 0;
- }
- return 1;
+ my $package = keys %main::packages ? join(' ', keys %main::packages) : "";
+
+ use Email::Send;
+ $Email::Send::Sendmail::SENDMAIL = '/usr/sbin/sendmail';
+
+ my $message = <<__MESSAGE__;
+To: $addr
+From: dak\@ftp-master.debian.org
+Subject: $subject
+X-Debian: DAK
+__MESSAGE__
+
+ if (length $package) {
+ $message .= "X-Debian-Package: $package\n";
+ }
+
+ $message .= "\n$text";
+
+ my $mail = Email::Send->new;
+ for ( qw[Sendmail SMTP] ) {
+ $mail->mailer($_) and last if $mail->mailer_available($_);
+ }
+
+ my $ret = $mail->send($message);
+ if ($ret && $ret !~ /Message sent|success/) {
+ return 0;
+ }
+
+ return 1;