my ($msg) = (@_);
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;
if (Param("mail_delivery_method") eq "sendmail" && !Param("sendmailnow")) {
push @args, "-ODeliveryMode=deferred";
}
# Set mail_delivery_method to SMTP and prompt for SMTP server
-# if running on Windows and set to sendmail (Mail::Mailer doesn't
-# support sendmail on Windows)
-if ($^O =~ /MSWin32/i && Param('mail_delivery_method') eq 'sendmail') {
+# if running on Windows and no third party sendmail wrapper
+# is available
+if ($^O =~ /MSWin32/i
+ && Param('mail_delivery_method') eq 'sendmail'
+ && !-e SENDMAIL_EXE)
+{
print "\nBugzilla requires an SMTP server to function on Windows.\n" .
"Please enter your SMTP server's hostname: ";
my $smtp = $answer{'SMTP_SERVER'}
use Bugzilla::Config qw(:DEFAULT $templatedir $webdotdir);
use Bugzilla::Util;
+use Bugzilla::Constants;
# Checking functions for the various values
# Some generic checking functions are included in Bugzilla::Config
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.
#
# Each definition is a hash with keys:
name => 'mail_delivery_method',
desc => 'Defines how email is sent, or if it is sent at all.<br><ul>' .
'<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' .
'in data/mailer.testfile instead of being sent. For more ' .
'information, see the Mail::Mailer manual.</li>' .
'stored.</li></ul>' ,
type => 's',
choices => $^O =~ /MSWin32/i
- ? ['smtp', 'testfile', 'none']
+ ? ['smtp', 'testfile', 'sendmail', 'none']
: ['sendmail', 'smtp', 'qmail', 'testfile', 'none'],
default => 'sendmail',
- checker => \&check_multi
+ checker => \&check_mail_delivery_method
},
{