From d652763b3fe4ae1256736c188c203f80b3b8f8f8 Mon Sep 17 00:00:00 2001 From: "travis%sedsystems.ca" <> Date: Wed, 2 Feb 2005 04:00:17 +0000 Subject: Bug 277437 : Use Mail::Mailer (Perl module) for mail delivery Patch by Andrei Benea r=vladd a=justdave --- Bugzilla/BugMail.pm | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'Bugzilla/BugMail.pm') diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index 6b77f6d94..c682b4d5c 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -35,6 +35,9 @@ use Bugzilla::RelationSet; use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Util; +use Mail::Mailer; +use Mail::Header; + # This code is really ugly. It was a commandline interface, then it was moved # There are package-global variables which we rely on ProcessOneBug to clean # up each time, and other sorts of fun. @@ -877,23 +880,27 @@ sub NewProcessOnePerson ($$$$$$$$$$$$$) { return 1; } -# XXX: Should eventually add $mail_from and $mail_to options to -# control the SMTP Envelope. -mkanat sub MessageToMTA ($) { - my ($msg) = (@_); + my ($msg) = (@_); + return unless $enableSendMail; - my $sendmailparam = ""; - unless (Param("sendmailnow")) { - $sendmailparam = "-ODeliveryMode=deferred"; + my @args; + if (Param("maildeliverymethod") eq "sendmail" && Param("sendmailnow")) { + push @args, "-ODeliveryMode=deferred"; + } + if (Param("maildeliverymethod") eq "smtp") { + push @args, Server => Param("smtpserver"); } + my $mailer = new Mail::Mailer Param("maildeliverymethod"), @args; - if ($enableSendMail == 1) { - open(SENDMAIL, "|/usr/lib/sendmail $sendmailparam -t -i") || - die "Can't open sendmail"; + $msg =~ /(.*?)\n\n(.*)/ms; + my @header_lines = split(/\n/, $1); + my $body = $2; - print SENDMAIL trim($msg) . "\n"; - close SENDMAIL; - } + my $headers = new Mail::Header \@header_lines, Modify => 0; + $mailer->open($headers->header_hashref); + print $mailer $msg; + $mailer->close; } 1; -- cgit v1.2.3-24-g4f1b