Commit 0b42b63e authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 302418: re-enable sendmail support for Windows - Patch by byron jones (glob)…

Bug 302418: re-enable sendmail support for Windows - Patch by byron jones (glob) <bugzilla@glob.com.au> r=wurblzap a=justdave
parent ef9cdafc
...@@ -615,6 +615,14 @@ sub MessageToMTA { ...@@ -615,6 +615,14 @@ sub MessageToMTA {
my ($msg) = (@_); my ($msg) = (@_);
return if (Param('mail_delivery_method') eq "none"); return if (Param('mail_delivery_method') eq "none");
if (Param("mail_delivery_method") eq "sendmail" && $^O =~ /MSWin32/i) {
open(SENDMAIL, '|' . SENDMAIL_EXE . ' -t -i') ||
die "Failed to execute " . SENDMAIL_EXE . ": $!\n";
print SENDMAIL $msg;
close SENDMAIL;
return;
}
my @args; my @args;
if (Param("mail_delivery_method") eq "sendmail" && !Param("sendmailnow")) { if (Param("mail_delivery_method") eq "sendmail" && !Param("sendmailnow")) {
push @args, "-ODeliveryMode=deferred"; push @args, "-ODeliveryMode=deferred";
......
...@@ -89,6 +89,8 @@ use base qw(Exporter); ...@@ -89,6 +89,8 @@ use base qw(Exporter);
FULLTEXT_BUGLIST_LIMIT FULLTEXT_BUGLIST_LIMIT
ADMIN_GROUP_NAME ADMIN_GROUP_NAME
SENDMAIL_EXE
); );
@Bugzilla::Constants::EXPORT_OK = qw(contenttypes); @Bugzilla::Constants::EXPORT_OK = qw(contenttypes);
...@@ -238,4 +240,7 @@ use constant FULLTEXT_BUGLIST_LIMIT => 200; ...@@ -238,4 +240,7 @@ use constant FULLTEXT_BUGLIST_LIMIT => 200;
# Default administration group name. # Default administration group name.
use constant ADMIN_GROUP_NAME => 'admin'; use constant ADMIN_GROUP_NAME => 'admin';
# Path to sendmail.exe (Windows only)
use constant SENDMAIL_EXE => '/usr/lib/sendmail.exe';
1; 1;
...@@ -1182,9 +1182,12 @@ if (@oldparams) { ...@@ -1182,9 +1182,12 @@ if (@oldparams) {
} }
# Set mail_delivery_method to SMTP and prompt for SMTP server # Set mail_delivery_method to SMTP and prompt for SMTP server
# if running on Windows and set to sendmail (Mail::Mailer doesn't # if running on Windows and no third party sendmail wrapper
# support sendmail on Windows) # is available
if ($^O =~ /MSWin32/i && Param('mail_delivery_method') eq 'sendmail') { if ($^O =~ /MSWin32/i
&& Param('mail_delivery_method') eq 'sendmail'
&& !-e SENDMAIL_EXE)
{
print "\nBugzilla requires an SMTP server to function on Windows.\n" . print "\nBugzilla requires an SMTP server to function on Windows.\n" .
"Please enter your SMTP server's hostname: "; "Please enter your SMTP server's hostname: ";
my $smtp = $answer{'SMTP_SERVER'} my $smtp = $answer{'SMTP_SERVER'}
......
...@@ -54,6 +54,7 @@ use Socket; ...@@ -54,6 +54,7 @@ use Socket;
use Bugzilla::Config qw(:DEFAULT $templatedir $webdotdir); use Bugzilla::Config qw(:DEFAULT $templatedir $webdotdir);
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Constants;
# Checking functions for the various values # Checking functions for the various values
# Some generic checking functions are included in Bugzilla::Config # Some generic checking functions are included in Bugzilla::Config
...@@ -247,6 +248,18 @@ sub find_languages { ...@@ -247,6 +248,18 @@ sub find_languages {
return join(', ', @languages); return join(', ', @languages);
} }
sub check_mail_delivery_method {
my $check = check_multi(@_);
return $check if $check;
my $mailer = shift;
if ($mailer eq 'sendmail' && $^O =~ /MSWin32/i) {
# look for sendmail.exe
return "Failed to locate " . SENDMAIL_EXE
unless -e SENDMAIL_EXE;
}
return "";
}
# OK, here are the parameter definitions themselves. # OK, here are the parameter definitions themselves.
# #
# Each definition is a hash with keys: # Each definition is a hash with keys:
...@@ -694,7 +707,8 @@ sub find_languages { ...@@ -694,7 +707,8 @@ sub find_languages {
name => 'mail_delivery_method', name => 'mail_delivery_method',
desc => 'Defines how email is sent, or if it is sent at all.<br><ul>' . desc => 'Defines how email is sent, or if it is sent at all.<br><ul>' .
'<li>\'sendmail\', \'smtp\' and \'qmail\' are all MTAs. ' . '<li>\'sendmail\', \'smtp\' and \'qmail\' are all MTAs. ' .
'(only SMTP is available in Windows.)</li>' . 'You need to install a third-party sendmail replacement if ' .
'you want to use sendmail on Windows.' .
'<li>\'testfile\' is useful for debugging: all email is stored ' . '<li>\'testfile\' is useful for debugging: all email is stored ' .
'in data/mailer.testfile instead of being sent. For more ' . 'in data/mailer.testfile instead of being sent. For more ' .
'information, see the Mail::Mailer manual.</li>' . 'information, see the Mail::Mailer manual.</li>' .
...@@ -703,10 +717,10 @@ sub find_languages { ...@@ -703,10 +717,10 @@ sub find_languages {
'stored.</li></ul>' , 'stored.</li></ul>' ,
type => 's', type => 's',
choices => $^O =~ /MSWin32/i choices => $^O =~ /MSWin32/i
? ['smtp', 'testfile', 'none'] ? ['smtp', 'testfile', 'sendmail', 'none']
: ['sendmail', 'smtp', 'qmail', 'testfile', 'none'], : ['sendmail', 'smtp', 'qmail', 'testfile', 'none'],
default => 'sendmail', default => 'sendmail',
checker => \&check_multi checker => \&check_mail_delivery_method
}, },
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment