From 2873d2c5561a0b105bceba49b9079d3ff35401fc Mon Sep 17 00:00:00 2001 From: "wurblzap%gmail.com" Date: Wed, 2 Nov 2005 20:50:46 +0000 Subject: [PATCH] Bugzilla Bug 306207: sendmail support under Windows bypasses message encoding Patch by byron jones (glob) r=wurblzap, a=myk git-svn-id: svn://10.0.0.236/trunk@184056 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/Bugzilla/BugMail.pm | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/mozilla/webtools/bugzilla/Bugzilla/BugMail.pm b/mozilla/webtools/bugzilla/Bugzilla/BugMail.pm index c487c4a6c6f..e8e725011ac 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/BugMail.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/BugMail.pm @@ -630,10 +630,22 @@ sub MessageToMTA { my ($msg) = (@_); return if (Param('mail_delivery_method') eq "none"); + my ($header, $body) = $msg =~ /(.*?\n)\n(.*)/s ? ($1, $2) : ('', $msg); + my $headers; + + if (Param('utf8') and (!is_7bit_clean($header) or !is_7bit_clean($body))) { + ($headers, $body) = encode_message($header, $body); + } else { + my @header_lines = split(/\n/, $header); + $headers = new Mail::Header \@header_lines, Modify => 0; + } + 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; + print SENDMAIL $headers->as_string; + print SENDMAIL "\n"; + print SENDMAIL $body; close SENDMAIL; return; } @@ -650,16 +662,6 @@ sub MessageToMTA { $Mail::Mailer::testfile::config{outfile} = "$datadir/mailer.testfile"; } - my ($header, $body) = $msg =~ /(.*?\n)\n(.*)/s ? ($1, $2) : ('', $msg); - my $headers; - - if (Param('utf8') and (!is_7bit_clean($header) or !is_7bit_clean($body))) { - ($headers, $body) = encode_message($header, $body); - } else { - my @header_lines = split(/\n/, $header); - $headers = new Mail::Header \@header_lines, Modify => 0; - } - $mailer->open($headers->header_hashref); print $mailer $body; $mailer->close;