Skip to content

Commit 02461e0

Browse files
JoePerchesgitster
authored andcommitted
git-send-email.perl: fold multiple entry "Cc:" and multiple single line "RCPT TO:"s
Some MTAs reject Cc: lines longer than 78 chars. Avoid this by using the same join as "To:" ",\n\t" so each subsequent Cc entry is on a new line. RCPT TO: should have a single entry per line. see: http://www.ietf.org/rfc/rfc2821.txt Signed-off-by: Joe Perches <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1cd749c commit 02461e0

File tree

2 files changed

+78
-22
lines changed

2 files changed

+78
-22
lines changed

git-send-email.perl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ sub send_message
835835
$gitversion = Git::version();
836836
}
837837

838-
my $cc = join(", ", unique_email_list(@cc));
838+
my $cc = join(",\n\t", unique_email_list(@cc));
839839
my $ccline = "";
840840
if ($cc ne '') {
841841
$ccline = "\nCc: $cc";
@@ -976,7 +976,9 @@ sub send_message
976976
if ($smtp_server !~ m#^/#) {
977977
print "Server: $smtp_server\n";
978978
print "MAIL FROM:<$raw_from>\n";
979-
print "RCPT TO:".join(',',(map { "<$_>" } @recipients))."\n";
979+
foreach my $entry (@recipients) {
980+
print "RCPT TO:<$entry>\n";
981+
}
980982
} else {
981983
print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n";
982984
}

t/t9001-send-email.sh

Lines changed: 74 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,18 @@ cat >expected-show-all-headers <<\EOF
103103
Dry-OK. Log says:
104104
Server: relay.example.com
105105
MAIL FROM:<[email protected]>
106-
106+
107+
108+
109+
110+
111+
107112
From: Example <[email protected]>
108113
109-
114+
115+
116+
117+
110118
Subject: [PATCH 1/1] Second.
111119
Date: DATE-STRING
112120
Message-Id: MESSAGE-ID-STRING
@@ -164,7 +172,7 @@ test_expect_success 'cccmd works' '
164172
--smtp-server="$(pwd)/fake.sendmail" \
165173
cccmd.patch \
166174
&&
167-
grep ^Cc:.*[email protected] msgtxt1
175+
grep "^ [email protected]" msgtxt1
168176
'
169177

170178
z8=zzzzzzzz
@@ -278,10 +286,17 @@ cat >expected-suppress-sob <<\EOF
278286
Dry-OK. Log says:
279287
Server: relay.example.com
280288
MAIL FROM:<[email protected]>
281-
289+
290+
291+
292+
293+
282294
From: Example <[email protected]>
283295
284-
296+
297+
298+
299+
285300
Subject: [PATCH 1/1] Second.
286301
Date: DATE-STRING
287302
Message-Id: MESSAGE-ID-STRING
@@ -318,10 +333,15 @@ cat >expected-suppress-sob <<\EOF
318333
Dry-OK. Log says:
319334
Server: relay.example.com
320335
MAIL FROM:<[email protected]>
321-
336+
337+
338+
339+
322340
From: Example <[email protected]>
323341
324-
342+
343+
344+
325345
Subject: [PATCH 1/1] Second.
326346
Date: DATE-STRING
327347
Message-Id: MESSAGE-ID-STRING
@@ -344,10 +364,17 @@ cat >expected-suppress-cccmd <<\EOF
344364
Dry-OK. Log says:
345365
Server: relay.example.com
346366
MAIL FROM:<[email protected]>
347-
367+
368+
369+
370+
371+
348372
From: Example <[email protected]>
349373
350-
374+
375+
376+
377+
C O Mitter <[email protected]>
351378
Subject: [PATCH 1/1] Second.
352379
Date: DATE-STRING
353380
Message-Id: MESSAGE-ID-STRING
@@ -392,10 +419,17 @@ cat >expected-suppress-body <<\EOF
392419
Dry-OK. Log says:
393420
Server: relay.example.com
394421
MAIL FROM:<[email protected]>
395-
422+
423+
424+
425+
426+
396427
From: Example <[email protected]>
397428
398-
429+
430+
431+
432+
399433
Subject: [PATCH 1/1] Second.
400434
Date: DATE-STRING
401435
Message-Id: MESSAGE-ID-STRING
@@ -416,10 +450,15 @@ cat >expected-suppress-body-cccmd <<\EOF
416450
Dry-OK. Log says:
417451
Server: relay.example.com
418452
MAIL FROM:<[email protected]>
419-
453+
454+
455+
456+
420457
From: Example <[email protected]>
421458
422-
459+
460+
461+
423462
Subject: [PATCH 1/1] Second.
424463
Date: DATE-STRING
425464
Message-Id: MESSAGE-ID-STRING
@@ -440,10 +479,15 @@ cat >expected-suppress-sob <<\EOF
440479
Dry-OK. Log says:
441480
Server: relay.example.com
442481
MAIL FROM:<[email protected]>
443-
482+
483+
484+
485+
444486
From: Example <[email protected]>
445487
446-
488+
489+
490+
447491
Subject: [PATCH 1/1] Second.
448492
Date: DATE-STRING
449493
Message-Id: MESSAGE-ID-STRING
@@ -466,10 +510,17 @@ cat >expected-suppress-bodycc <<\EOF
466510
Dry-OK. Log says:
467511
Server: relay.example.com
468512
MAIL FROM:<[email protected]>
469-
513+
514+
515+
516+
517+
470518
From: Example <[email protected]>
471519
472-
520+
521+
522+
523+
C O Mitter <[email protected]>
473524
Subject: [PATCH 1/1] Second.
474525
Date: DATE-STRING
475526
Message-Id: MESSAGE-ID-STRING
@@ -489,10 +540,13 @@ cat >expected-suppress-cc <<\EOF
489540
Dry-OK. Log says:
490541
Server: relay.example.com
491542
MAIL FROM:<[email protected]>
492-
543+
544+
545+
493546
From: Example <[email protected]>
494547
495-
548+
549+
C O Mitter <[email protected]>
496550
Subject: [PATCH 1/1] Second.
497551
Date: DATE-STRING
498552
Message-Id: MESSAGE-ID-STRING
@@ -605,7 +659,7 @@ test_expect_success 'utf8 Cc is rfc2047 encoded' '
605659
606660
--smtp-server="$(pwd)/fake.sendmail" \
607661
outdir/*.patch &&
608-
grep "^Cc:" msgtxt1 |
662+
grep "^ " msgtxt1 |
609663
grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <[email protected]>"
610664
'
611665

0 commit comments

Comments
 (0)