From: lpsolit%gmail.com <> Date: Sat, 13 Aug 2005 22:04:29 +0000 (+0000) Subject: Bug 302418: re-enable sendmail support for Windows - Patch by byron jones (glob)... X-Git-Tag: bugzilla-2.20~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfc4d5efe0e42c13c5c3ace434a102231fe898bd;p=thirdparty%2Fbugzilla.git Bug 302418: re-enable sendmail support for Windows - Patch by byron jones (glob) r=wurblzap a=justdave --- diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index b6c5badfad..c0fc7d8829 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -620,6 +620,14 @@ sub MessageToMTA ($) { 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"; diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index a626294206..ce4801b932 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -87,6 +87,8 @@ use base qw(Exporter); EVT_FLAG_REQUESTED EVT_REQUESTED_FLAG FULLTEXT_BUGLIST_LIMIT + + SENDMAIL_EXE ); @Bugzilla::Constants::EXPORT_OK = qw(contenttypes); @@ -233,4 +235,7 @@ use constant GLOBAL_EVENTS => EVT_FLAG_REQUESTED, EVT_REQUESTED_FLAG; # a fulltext search. use constant FULLTEXT_BUGLIST_LIMIT => 200; +# Path to sendmail.exe (Windows only) +use constant SENDMAIL_EXE => '/usr/lib/sendmail.exe'; + 1; diff --git a/checksetup.pl b/checksetup.pl index 172dceaa8c..be6bbce498 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -1159,9 +1159,12 @@ if (@oldparams) { } # 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'} diff --git a/defparams.pl b/defparams.pl index 5b26ef4f93..c8900e7227 100644 --- a/defparams.pl +++ b/defparams.pl @@ -54,6 +54,7 @@ use Socket; 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 @@ -238,6 +239,18 @@ sub find_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. # # Each definition is a hash with keys: @@ -674,7 +687,8 @@ sub find_languages { name => 'mail_delivery_method', desc => 'Defines how email is sent, or if it is sent at all.
' , 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 }, {