Ensure clean addresses are always used with Net::SMTP
Always pass in clean addresses to Net::SMTP for the MAIL FROM, and use them on the SMTP non-quiet output as well. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Robin H. Johnson committed
Apr 25, 2007 at 19:37 UTC
2b69bfc23d89d2ec5507bc6906b533e8429b313d
1 file changed
+5
-4
git-send-email.perl
+5
-4
@@ -476,6 +476,7 @@ X-Mailer: git-send-email $gitversion
476
}
477
478
my @sendmail_parameters = ('-i', @recipients);
479
+ my $raw_from = extract_valid_address($from);
480
481
if ($dry_run) {
482
# We don't want to send the email.
@@ -490,7 +491,7 @@ X-Mailer: git-send-email $gitversion
491
} else {
492
require Net::SMTP;
493
$smtp ||= Net::SMTP->new( $smtp_server );
493
- $smtp->mail( $from ) or die $smtp->message;
494
+ $smtp->mail( $raw_from ) or die $smtp->message;
495
$smtp->to( @recipients ) or die $smtp->message;
496
$smtp->data or die $smtp->message;
497
$smtp->datasend("$header\n$message") or die $smtp->message;
@@ -501,10 +502,10 @@ X-Mailer: git-send-email $gitversion
502
printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
503
} else {
504
print (($dry_run ? "Dry-" : "")."OK. Log says:\nDate: $date\n");
504
- if ($smtp) {
505
+ if ($smtp_server !~ m#^/#) {
506
print "Server: $smtp_server\n";
506
- print "MAIL FROM: $from\n";
507
- print "RCPT TO: ".join(',',@recipients)."\n";
507
+ print "MAIL FROM:<$raw_from>\n";
508
+ print "RCPT TO:".join(',',(map { "<$_>" } @recipients))."\n";
509
} else {
510
print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n";
511
}