]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 277437 : Use Mail::Mailer (Perl module) for mail delivery
authortravis%sedsystems.ca <>
Wed, 2 Feb 2005 04:00:17 +0000 (04:00 +0000)
committertravis%sedsystems.ca <>
Wed, 2 Feb 2005 04:00:17 +0000 (04:00 +0000)
Patch by Andrei Benea <abenea@gmail.com>  r=vladd  a=justdave

Bugzilla/BugMail.pm
checksetup.pl
defparams.pl

index 6b77f6d9410e314dad27dcaf6f85f569b5469323..c682b4d5c234c97be0ac7553a51e41139176b5df 100644 (file)
@@ -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;
index 1a8f46f5555849a68d94ce722f1c4b405a09e2f9..daabfa8f4b7d98576ed4af5730429b6e83da563b 100755 (executable)
@@ -302,7 +302,11 @@ my $modules = [
     { 
         name => 'Text::Wrap', 
         version => '2001.0131' 
-    } 
+    },
+    { 
+        name => 'Mail::Mailer', 
+        version => '1.65'
+    },
 ];
 
 my %ppm_modules = (
@@ -318,6 +322,7 @@ my %ppm_modules = (
     'GD'                => 'GD',
     'GD::Graph'         => 'GDGraph',
     'GD::Text::Align'   => 'GDTextUtil',
+    'Mail::Mailer'      => 'MailTools',
 );
 
 sub install_command {
index 29c4d27ad12034096a74426833eaf6e05039b1af..fd681e96681460fc7ee5afb354a6ec6842eec408 100644 (file)
@@ -670,6 +670,17 @@ sub find_languages {
    default => ''
   },
 
+  {
+   name => 'maildeliverymethod',
+   desc => 'The method used for mail delivery. The testfile method ' .
+           'is useful for debugging (for more information see the ' .
+           'Mail::Mailer manual)',
+   type => 's',
+   choices => ['sendmail', 'smtp', 'qmail', 'testfile'],
+   default => 'sendmail',
+   checker => \&check_multi
+  },
+
   {
    name => 'sendmailnow',
    desc => 'Sites using anything older than version 8.12 of \'sendmail\' ' .
@@ -683,6 +694,13 @@ sub find_languages {
    default => 1
   },
 
+  {
+   name => 'smtpserver',
+   desc => 'The SMTP server address (if using SMTP for mail delivery).',
+   type => 't',
+   default => 'localhost'
+  },
+
   {
    name => 'passwordmail',
    desc => 'The email that gets sent to people to tell them their password.' .