summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Mailer.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/Mailer.pm')
-rw-r--r--Bugzilla/Mailer.pm57
1 files changed, 21 insertions, 36 deletions
diff --git a/Bugzilla/Mailer.pm b/Bugzilla/Mailer.pm
index 576f69da8..5c0d85d33 100644
--- a/Bugzilla/Mailer.pm
+++ b/Bugzilla/Mailer.pm
@@ -23,15 +23,10 @@ use Date::Format qw(time2str);
use Encode qw(encode);
use Encode::MIME::Header;
-use Email::Address;
use Email::MIME;
-# Return::Value 1.666002 pollutes the error log with warnings about this
-# deprecated module. We have to set NO_CLUCK = 1 before loading Email::Send
-# to disable these warnings.
-BEGIN {
- $Return::Value::NO_CLUCK = 1;
-}
-use Email::Send;
+use Email::Sender::Simple qw(sendmail);
+use Email::Sender::Transport::SMTP;
+use Email::Sender::Transport::Sendmail;
sub MessageToMTA {
my ($msg, $send_now) = (@_);
@@ -55,8 +50,6 @@ sub MessageToMTA {
# Email::MIME doesn't do this for us. We use \015 (CR) and \012 (LF)
# directly because Perl translates "\n" depending on what platform
# you're running on. See http://perldoc.perl.org/perlport.html#Newlines
- # We check for multiple CRs because of this Template-Toolkit bug:
- # https://rt.cpan.org/Ticket/Display.html?id=43345
$msg =~ s/(?:\015+)?\012/\015\012/msg;
$email = new Email::MIME($msg);
}
@@ -108,21 +101,14 @@ sub MessageToMTA {
my $from = $email->header('From');
- my ($hostname, @args);
- my $mailer_class = $method;
+ my $hostname;
+ my $transport;
if ($method eq "Sendmail") {
- $mailer_class = 'Bugzilla::Send::Sendmail';
if (ON_WINDOWS) {
- $Email::Send::Sendmail::SENDMAIL = SENDMAIL_EXE;
+ $transport = Email::Sender::Transport::Sendmail->new({ sendmail => SENDMAIL_EXE });
}
- push @args, "-i";
- # We want to make sure that we pass *only* an email address.
- if ($from) {
- my ($email_obj) = Email::Address->parse($from);
- if ($email_obj) {
- my $from_email = $email_obj->address;
- push(@args, "-f$from_email") if $from_email;
- }
+ else {
+ $transport = Email::Sender::Transport::Sendmail->new();
}
}
else {
@@ -141,16 +127,16 @@ sub MessageToMTA {
}
if ($method eq "SMTP") {
- push @args, Host => Bugzilla->params->{"smtpserver"},
- username => Bugzilla->params->{"smtp_username"},
- password => Bugzilla->params->{"smtp_password"},
- Hello => $hostname,
- ssl => Bugzilla->params->{'smtp_ssl'},
- Debug => Bugzilla->params->{'smtp_debug'};
+ $transport = Email::Sender::Transport::SMTP->new({
+ host => Bugzilla->params->{'smtpserver'},
+ sasl_username => Bugzilla->params->{'smtp_username'},
+ sasl_password => Bugzilla->params->{'smtp_password'},
+ helo => $hostname,
+ ssl => Bugzilla->params->{'smtp_ssl'},
+ debug => Bugzilla->params->{'smtp_debug'} });
}
- Bugzilla::Hook::process('mailer_before_send',
- { email => $email, mailer_args => \@args });
+ Bugzilla::Hook::process('mailer_before_send', { email => $email });
return if $email->header('to') eq '';
@@ -185,13 +171,12 @@ sub MessageToMTA {
close TESTFILE;
}
else {
- # This is useful for both Sendmail and Qmail, so we put it out here.
+ # This is useful for Sendmail, so we put it out here.
local $ENV{PATH} = SENDMAIL_PATH;
- my $mailer = Email::Send->new({ mailer => $mailer_class,
- mailer_args => \@args });
- my $retval = $mailer->send($email);
- ThrowCodeError('mail_send_error', { msg => $retval, mail => $email })
- if !$retval;
+ eval { sendmail($email, { transport => $transport }) };
+ if ($@) {
+ ThrowCodeError('mail_send_error', { msg => $@->message, mail => $email });
+ }
}
}