@matheusbsbs / matheus-bagliano / commits / 02461e0e28
Fork 0

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 <joe@perches.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Joe Perches committed Oct 8, 2009 at 10:03 UTC 02461e0e2833753151ed71899f075c94e5fc495b
2 files changed +78 -22
git-send-email.perl
+4 -2
@@ -835,7 +835,7 @@ sub send_message
835 $gitversion = Git::version();
836 }
837
838 - my $cc = join(", ", unique_email_list(@cc));
838 + my $cc = join(",\n\t", unique_email_list(@cc));
839 my $ccline = "";
840 if ($cc ne '') {
841 $ccline = "\nCc: $cc";
@@ -976,7 +976,9 @@ X-Mailer: git-send-email $gitversion
976 if ($smtp_server !~ m#^/#) {
977 print "Server: $smtp_server\n";
978 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 + }
982 } else {
983 print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n";
984 }
t/t9001-send-email.sh
+74 -20
@@ -103,10 +103,18 @@ cat >expected-show-all-headers <<\EOF
103 Dry-OK. Log says:
104 Server: relay.example.com
105 MAIL FROM:<from@example.com>
106 -RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<bcc@example.com>
106 +RCPT TO:<to@example.com>
107 +RCPT TO:<cc@example.com>
108 +RCPT TO:<author@example.com>
109 +RCPT TO:<one@example.com>
110 +RCPT TO:<two@example.com>
111 +RCPT TO:<bcc@example.com>
112 From: Example <from@example.com>
113 To: to@example.com
109 -Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com
114 +Cc: cc@example.com,
115 + A <author@example.com>,
116 + One <one@example.com>,
117 + two@example.com
118 Subject: [PATCH 1/1] Second.
119 Date: DATE-STRING
120 Message-Id: MESSAGE-ID-STRING
@@ -164,7 +172,7 @@ test_expect_success 'cccmd works' '
172 --smtp-server="$(pwd)/fake.sendmail" \
173 cccmd.patch \
174 &&
167 - grep ^Cc:.*cccmd@example.com msgtxt1
175 + grep "^ cccmd@example.com" msgtxt1
176 '
177
178 z8=zzzzzzzz
@@ -278,10 +286,17 @@ cat >expected-suppress-sob <<\EOF
286 Dry-OK. Log says:
287 Server: relay.example.com
288 MAIL FROM:<from@example.com>
281 -RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
289 +RCPT TO:<to@example.com>
290 +RCPT TO:<cc@example.com>
291 +RCPT TO:<author@example.com>
292 +RCPT TO:<one@example.com>
293 +RCPT TO:<two@example.com>
294 From: Example <from@example.com>
295 To: to@example.com
284 -Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com
296 +Cc: cc@example.com,
297 + A <author@example.com>,
298 + One <one@example.com>,
299 + two@example.com
300 Subject: [PATCH 1/1] Second.
301 Date: DATE-STRING
302 Message-Id: MESSAGE-ID-STRING
@@ -318,10 +333,15 @@ cat >expected-suppress-sob <<\EOF
333 Dry-OK. Log says:
334 Server: relay.example.com
335 MAIL FROM:<from@example.com>
321 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
336 +RCPT TO:<to@example.com>
337 +RCPT TO:<author@example.com>
338 +RCPT TO:<one@example.com>
339 +RCPT TO:<two@example.com>
340 From: Example <from@example.com>
341 To: to@example.com
324 -Cc: A <author@example.com>, One <one@example.com>, two@example.com
342 +Cc: A <author@example.com>,
343 + One <one@example.com>,
344 + two@example.com
345 Subject: [PATCH 1/1] Second.
346 Date: DATE-STRING
347 Message-Id: MESSAGE-ID-STRING
@@ -344,10 +364,17 @@ cat >expected-suppress-cccmd <<\EOF
364 Dry-OK. Log says:
365 Server: relay.example.com
366 MAIL FROM:<from@example.com>
347 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
367 +RCPT TO:<to@example.com>
368 +RCPT TO:<author@example.com>
369 +RCPT TO:<one@example.com>
370 +RCPT TO:<two@example.com>
371 +RCPT TO:<committer@example.com>
372 From: Example <from@example.com>
373 To: to@example.com
350 -Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
374 +Cc: A <author@example.com>,
375 + One <one@example.com>,
376 + two@example.com,
377 + C O Mitter <committer@example.com>
378 Subject: [PATCH 1/1] Second.
379 Date: DATE-STRING
380 Message-Id: MESSAGE-ID-STRING
@@ -392,10 +419,17 @@ cat >expected-suppress-body <<\EOF
419 Dry-OK. Log says:
420 Server: relay.example.com
421 MAIL FROM:<from@example.com>
395 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<cc-cmd@example.com>
422 +RCPT TO:<to@example.com>
423 +RCPT TO:<author@example.com>
424 +RCPT TO:<one@example.com>
425 +RCPT TO:<two@example.com>
426 +RCPT TO:<cc-cmd@example.com>
427 From: Example <from@example.com>
428 To: to@example.com
398 -Cc: A <author@example.com>, One <one@example.com>, two@example.com, cc-cmd@example.com
429 +Cc: A <author@example.com>,
430 + One <one@example.com>,
431 + two@example.com,
432 + cc-cmd@example.com
433 Subject: [PATCH 1/1] Second.
434 Date: DATE-STRING
435 Message-Id: MESSAGE-ID-STRING
@@ -416,10 +450,15 @@ cat >expected-suppress-body-cccmd <<\EOF
450 Dry-OK. Log says:
451 Server: relay.example.com
452 MAIL FROM:<from@example.com>
419 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
453 +RCPT TO:<to@example.com>
454 +RCPT TO:<author@example.com>
455 +RCPT TO:<one@example.com>
456 +RCPT TO:<two@example.com>
457 From: Example <from@example.com>
458 To: to@example.com
422 -Cc: A <author@example.com>, One <one@example.com>, two@example.com
459 +Cc: A <author@example.com>,
460 + One <one@example.com>,
461 + two@example.com
462 Subject: [PATCH 1/1] Second.
463 Date: DATE-STRING
464 Message-Id: MESSAGE-ID-STRING
@@ -440,10 +479,15 @@ cat >expected-suppress-sob <<\EOF
479 Dry-OK. Log says:
480 Server: relay.example.com
481 MAIL FROM:<from@example.com>
443 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
482 +RCPT TO:<to@example.com>
483 +RCPT TO:<author@example.com>
484 +RCPT TO:<one@example.com>
485 +RCPT TO:<two@example.com>
486 From: Example <from@example.com>
487 To: to@example.com
446 -Cc: A <author@example.com>, One <one@example.com>, two@example.com
488 +Cc: A <author@example.com>,
489 + One <one@example.com>,
490 + two@example.com
491 Subject: [PATCH 1/1] Second.
492 Date: DATE-STRING
493 Message-Id: MESSAGE-ID-STRING
@@ -466,10 +510,17 @@ cat >expected-suppress-bodycc <<\EOF
510 Dry-OK. Log says:
511 Server: relay.example.com
512 MAIL FROM:<from@example.com>
469 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
513 +RCPT TO:<to@example.com>
514 +RCPT TO:<author@example.com>
515 +RCPT TO:<one@example.com>
516 +RCPT TO:<two@example.com>
517 +RCPT TO:<committer@example.com>
518 From: Example <from@example.com>
519 To: to@example.com
472 -Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
520 +Cc: A <author@example.com>,
521 + One <one@example.com>,
522 + two@example.com,
523 + C O Mitter <committer@example.com>
524 Subject: [PATCH 1/1] Second.
525 Date: DATE-STRING
526 Message-Id: MESSAGE-ID-STRING
@@ -489,10 +540,13 @@ cat >expected-suppress-cc <<\EOF
540 Dry-OK. Log says:
541 Server: relay.example.com
542 MAIL FROM:<from@example.com>
492 -RCPT TO:<to@example.com>,<author@example.com>,<committer@example.com>
543 +RCPT TO:<to@example.com>
544 +RCPT TO:<author@example.com>
545 +RCPT TO:<committer@example.com>
546 From: Example <from@example.com>
547 To: to@example.com
495 -Cc: A <author@example.com>, C O Mitter <committer@example.com>
548 +Cc: A <author@example.com>,
549 + C O Mitter <committer@example.com>
550 Subject: [PATCH 1/1] Second.
551 Date: DATE-STRING
552 Message-Id: MESSAGE-ID-STRING
@@ -605,7 +659,7 @@ test_expect_success 'utf8 Cc is rfc2047 encoded' '
659 --to=nobody@example.com \
660 --smtp-server="$(pwd)/fake.sendmail" \
661 outdir/*.patch &&
608 - grep "^Cc:" msgtxt1 |
662 + grep "^ " msgtxt1 |
663 grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
664 '
665