Commit 6ad87317 authored by bugzilla%glob.com.au's avatar bugzilla%glob.com.au

Bug 94293: Sendmail "from" header can not be configured in one config file, From…

Bug 94293: Sendmail "from" header can not be configured in one config file, From header broken in SMTP Patch by Jochen Wiedmann <jochen.wiedmann@gmail.com> r=glob,a=justdave
parent c8242c1e
...@@ -639,8 +639,16 @@ sub MessageToMTA { ...@@ -639,8 +639,16 @@ sub MessageToMTA {
$headers = new Mail::Header \@header_lines, Modify => 0; $headers = new Mail::Header \@header_lines, Modify => 0;
} }
my $from = $headers->get('from');
if (Param("mail_delivery_method") eq "sendmail" && $^O =~ /MSWin32/i) { if (Param("mail_delivery_method") eq "sendmail" && $^O =~ /MSWin32/i) {
open(SENDMAIL, '|' . SENDMAIL_EXE . ' -t -i') || my $cmd = '|' . SENDMAIL_EXE . ' -t -i';
if ($from) {
# We're on Windows, thus no danger of command injection
# via $from. In other words, it is safe to embed $from.
$cmd .= qq# -f"$from"#;
}
open(SENDMAIL, $cmd) ||
die "Failed to execute " . SENDMAIL_EXE . ": $!\n"; die "Failed to execute " . SENDMAIL_EXE . ": $!\n";
print SENDMAIL $headers->as_string; print SENDMAIL $headers->as_string;
print SENDMAIL "\n"; print SENDMAIL "\n";
...@@ -652,12 +660,18 @@ sub MessageToMTA { ...@@ -652,12 +660,18 @@ sub MessageToMTA {
my @args; my @args;
if (Param("mail_delivery_method") eq "sendmail") { if (Param("mail_delivery_method") eq "sendmail") {
push @args, "-i"; push @args, "-i";
if ($from) {
push(@args, "-f$from");
}
} }
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";
} }
if (Param("mail_delivery_method") eq "smtp") { if (Param("mail_delivery_method") eq "smtp") {
push @args, Server => Param("smtpserver"); push @args, Server => Param("smtpserver");
if ($from) {
$ENV{'MAILADDRESS'} = $from;
}
} }
my $mailer = new Mail::Mailer Param("mail_delivery_method"), @args; my $mailer = new Mail::Mailer Param("mail_delivery_method"), @args;
if (Param("mail_delivery_method") eq "testfile") { if (Param("mail_delivery_method") eq "testfile") {
......
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