aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2014-10-01 12:15:23 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2014-10-01 12:15:23 +0200
commit0ff4174b5ea7f839562f5109defab1c2ac92e735 (patch)
tree990c69d4b1e9c2f318e7461f8f88c63ded6dde94
parentFix bustage due to bug 1061247 (diff)
downloadbugzilla-0ff4174b5ea7f839562f5109defab1c2ac92e735.tar.gz
bugzilla-0ff4174b5ea7f839562f5109defab1c2ac92e735.tar.bz2
bugzilla-0ff4174b5ea7f839562f5109defab1c2ac92e735.zip
Bug 1070640: Update (and rename) Bugzilla::Send::Sendmail to work with Email::Sender::Transport::Sendmail
r=dylan a=justdave
-rw-r--r--Bugzilla/Mailer.pm6
-rw-r--r--Bugzilla/Sender/Transport/Sendmail.pm (renamed from Bugzilla/Send/Sendmail.pm)47
2 files changed, 22 insertions, 31 deletions
diff --git a/Bugzilla/Mailer.pm b/Bugzilla/Mailer.pm
index 5c0d85d33..3c8815306 100644
--- a/Bugzilla/Mailer.pm
+++ b/Bugzilla/Mailer.pm
@@ -26,7 +26,7 @@ use Encode::MIME::Header;
use Email::MIME;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP;
-use Email::Sender::Transport::Sendmail;
+use Bugzilla::Sender::Transport::Sendmail;
sub MessageToMTA {
my ($msg, $send_now) = (@_);
@@ -105,10 +105,10 @@ sub MessageToMTA {
my $transport;
if ($method eq "Sendmail") {
if (ON_WINDOWS) {
- $transport = Email::Sender::Transport::Sendmail->new({ sendmail => SENDMAIL_EXE });
+ $transport = Bugzilla::Sender::Transport::Sendmail->new({ sendmail => SENDMAIL_EXE });
}
else {
- $transport = Email::Sender::Transport::Sendmail->new();
+ $transport = Bugzilla::Sender::Transport::Sendmail->new();
}
}
else {
diff --git a/Bugzilla/Send/Sendmail.pm b/Bugzilla/Sender/Transport/Sendmail.pm
index 48312b2fa..49f00777f 100644
--- a/Bugzilla/Send/Sendmail.pm
+++ b/Bugzilla/Sender/Transport/Sendmail.pm
@@ -5,58 +5,49 @@
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
-package Bugzilla::Send::Sendmail;
+package Bugzilla::Sender::Transport::Sendmail;
use 5.10.1;
use strict;
use warnings;
-use parent qw(Email::Send::Sendmail);
+use parent qw(Email::Sender::Transport::Sendmail);
-use Return::Value;
-use Symbol qw(gensym);
+use Email::Sender::Failure;
-sub send {
- my ($class, $message, @args) = @_;
- my $mailer = $class->_find_sendmail;
+sub send_email {
+ my ($self, $email, $envelope) = @_;
- return failure "Couldn't find 'sendmail' executable in your PATH"
- ." and Email::Send::Sendmail::SENDMAIL is not set"
- unless $mailer;
+ my $pipe = $self->_sendmail_pipe($envelope);
- return failure "Found $mailer but cannot execute it"
- unless -x $mailer;
-
- local $SIG{'CHLD'} = 'DEFAULT';
+ my $string = $email->as_string;
+ $string =~ s/\x0D\x0A/\x0A/g unless $^O eq 'MSWin32';
- my $pipe = gensym;
+ print $pipe $string
+ or Email::Sender::Failure->throw("couldn't send message to sendmail: $!");
- open($pipe, "| $mailer -t -oi @args")
- || return failure "Error executing $mailer: $!";
- print($pipe $message->as_string)
- || return failure "Error printing via pipe to $mailer: $!";
unless (close $pipe) {
- return failure "error when closing pipe to $mailer: $!" if $!;
+ Email::Sender::Failure->throw("error when closing pipe to sendmail: $!") if $!;
my ($error_message, $is_transient) = _map_exitcode($? >> 8);
if (Bugzilla->params->{'use_mailer_queue'}) {
# Return success for errors which are fatal so Bugzilla knows to
- # remove them from the queue
+ # remove them from the queue.
if ($is_transient) {
- return failure "error when closing pipe to $mailer: $error_message";
+ Email::Sender::Failure->throw("error when closing pipe to sendmail: $error_message");
} else {
- warn "error when closing pipe to $mailer: $error_message\n";
- return success;
+ warn "error when closing pipe to sendmail: $error_message\n";
+ return $self->success;
}
} else {
- return failure "error when closing pipe to $mailer: $error_message";
+ Email::Sender::Failure->throw("error when closing pipe to sendmail: $error_message");
}
}
- return success;
+ return $self->success;
}
sub _map_exitcode {
# Returns (error message, is_transient)
- # from the sendmail source (sendmail/sysexit.h)
+ # from the sendmail source (sendmail/sysexits.h)
my $code = shift;
if ($code == 64) {
return ("Command line usage error (EX_USAGE)", 1);
@@ -99,6 +90,6 @@ sub _map_exitcode {
=over
-=item send
+=item send_email
=back