Code

Ensure clean addresses are always used with Net::SMTP
authorRobin H. Johnson <robbat2@gentoo.org>
Thu, 26 Apr 2007 02:37:21 +0000 (19:37 -0700)
committerJunio C Hamano <junkio@cox.net>
Thu, 26 Apr 2007 04:12:16 +0000 (21:12 -0700)
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>
git-send-email.perl

index b6022929042e0b03f395c553e93c6f47a35c6990..35c4722a15baca61b78d04fd74a446ff63200819 100755 (executable)
@@ -476,6 +476,7 @@ X-Mailer: git-send-email $gitversion
        }
 
        my @sendmail_parameters = ('-i', @recipients);
+       my $raw_from = extract_valid_address($from);
 
        if ($dry_run) {
                # We don't want to send the email.
@@ -490,7 +491,7 @@ X-Mailer: git-send-email $gitversion
        } else {
                require Net::SMTP;
                $smtp ||= Net::SMTP->new( $smtp_server );
-               $smtp->mail( $from ) or die $smtp->message;
+               $smtp->mail( $raw_from ) or die $smtp->message;
                $smtp->to( @recipients ) or die $smtp->message;
                $smtp->data or die $smtp->message;
                $smtp->datasend("$header\n$message") or die $smtp->message;
@@ -501,10 +502,10 @@ X-Mailer: git-send-email $gitversion
                printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
        } else {
                print (($dry_run ? "Dry-" : "")."OK. Log says:\nDate: $date\n");
-               if ($smtp) {
+               if ($smtp_server !~ m#^/#) {
                        print "Server: $smtp_server\n";
-                       print "MAIL FROM: $from\n";
-                       print "RCPT TO: ".join(',',@recipients)."\n";
+                       print "MAIL FROM:<$raw_from>\n";
+                       print "RCPT TO:".join(',',(map { "<$_>" } @recipients))."\n";
                } else {
                        print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n";
                }