Skip to content

Commit d11c943

Browse files
chrissicoolgitster
authored andcommitted
send-email: support separate Reply-To address
In some projects contributions from groups are only accepted from a common group email address. But every individual may want to receive replies to her own personal address. That's what we have 'Reply-To' headers for in SMTP. So introduce an optional '--reply-to' command line option. This patch re-uses the $reply_to variable. This could break out-of-tree patches! Signed-off-by: Christian Ludwig <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 15dc3b9 commit d11c943

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

Documentation/git-send-email.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ See the CONFIGURATION section for `sendemail.multiEdit`.
8484
the value of GIT_AUTHOR_IDENT, or GIT_COMMITTER_IDENT if that is not
8585
set, as returned by "git var -l".
8686

87+
--reply-to=<address>::
88+
Specify the address where replies from recipients should go to.
89+
Use this if replies to messages should go to another address than what
90+
is specified with the --from parameter.
91+
8792
--in-reply-to=<identifier>::
8893
Make the first mail (or all the mails with `--no-thread`) appear as a
8994
reply to the given Message-Id, which avoids breaking threads to

contrib/completion/git-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2081,7 +2081,7 @@ _git_send_email ()
20812081
--compose --confirm= --dry-run --envelope-sender
20822082
--from --identity
20832083
--in-reply-to --no-chain-reply-to --no-signed-off-by-cc
2084-
--no-suppress-from --no-thread --quiet
2084+
--no-suppress-from --no-thread --quiet --reply-to
20852085
--signed-off-by-cc --smtp-pass --smtp-server
20862086
--smtp-server-port --smtp-encryption= --smtp-user
20872087
--subject --suppress-cc= --suppress-from --thread --to

git-send-email.perl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ sub usage {
5656
--[no-]cc <str> * Email Cc:
5757
--[no-]bcc <str> * Email Bcc:
5858
--subject <str> * Email "Subject:"
59+
--reply-to <str> * Email "Reply-To:"
5960
--in-reply-to <str> * Email "In-Reply-To:"
6061
--[no-]xmailer * Add "X-Mailer:" header (default).
6162
--[no-]annotate * Review each patch that will be sent in an editor.
@@ -166,7 +167,7 @@ sub format_2822_time {
166167

167168
# Variables we fill in automatically, or via prompting:
168169
my (@to,$no_to,@initial_to,@cc,$no_cc,@initial_cc,@bcclist,$no_bcc,@xh,
169-
$initial_in_reply_to,$initial_subject,@files,
170+
$initial_in_reply_to,$reply_to,$initial_subject,@files,
170171
$author,$sender,$smtp_authpass,$annotate,$use_xmailer,$compose,$time);
171172

172173
my $envelope_sender;
@@ -315,6 +316,7 @@ sub signal_handler {
315316
$rc = GetOptions(
316317
"sender|from=s" => \$sender,
317318
"in-reply-to=s" => \$initial_in_reply_to,
319+
"reply-to=s" => \$reply_to,
318320
"subject=s" => \$initial_subject,
319321
"to=s" => \@initial_to,
320322
"to-cmd=s" => \$to_cmd,
@@ -677,6 +679,7 @@ sub get_patch_subject {
677679
my $tpl_sender = $sender || $repoauthor || $repocommitter || '';
678680
my $tpl_subject = $initial_subject || '';
679681
my $tpl_in_reply_to = $initial_in_reply_to || '';
682+
my $tpl_reply_to = $reply_to || '';
680683

681684
print $c <<EOT1, Git::prefix_lines("GIT: ", __ <<EOT2), <<EOT3;
682685
From $tpl_sender # This line is ignored.
@@ -688,6 +691,7 @@ sub get_patch_subject {
688691
Clear the body content if you don't wish to send a summary.
689692
EOT2
690693
From: $tpl_sender
694+
Reply-To: $tpl_reply_to
691695
Subject: $tpl_subject
692696
In-Reply-To: $tpl_in_reply_to
693697
@@ -730,6 +734,9 @@ sub get_patch_subject {
730734
if ($parsed_email{'In-Reply-To'}) {
731735
$initial_in_reply_to = delete($parsed_email{'In-Reply-To'});
732736
}
737+
if ($parsed_email{'Reply-To'}) {
738+
$reply_to = delete($parsed_email{'Reply-To'});
739+
}
733740
if ($parsed_email{'Subject'}) {
734741
$initial_subject = delete($parsed_email{'Subject'});
735742
print $c2 "Subject: " .
@@ -923,6 +930,12 @@ sub expand_one_alias {
923930
$initial_in_reply_to = "<$initial_in_reply_to>" if $initial_in_reply_to ne '';
924931
}
925932

933+
if (defined $reply_to) {
934+
$reply_to =~ s/^\s+|\s+$//g;
935+
($reply_to) = expand_aliases($reply_to);
936+
$reply_to = sanitize_address($reply_to);
937+
}
938+
926939
if (!defined $smtp_server) {
927940
my @sendmail_paths = qw( /usr/sbin/sendmail /usr/lib/sendmail );
928941
push @sendmail_paths, map {"$_/sendmail"} split /:/, $ENV{PATH};
@@ -1354,6 +1367,9 @@ sub send_message {
13541367
$header .= "In-Reply-To: $in_reply_to\n";
13551368
$header .= "References: $references\n";
13561369
}
1370+
if ($reply_to) {
1371+
$header .= "Reply-To: $reply_to\n";
1372+
}
13571373
if (@xh) {
13581374
$header .= join("\n", @xh) . "\n";
13591375
}

t/t9001-send-email.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ Message-Id: MESSAGE-ID-STRING
199199
X-Mailer: X-MAILER-STRING
200200
In-Reply-To: <[email protected]>
201201
References: <[email protected]>
202+
Reply-To: Reply <[email protected]>
202203
203204
Result: OK
204205
EOF
@@ -291,6 +292,7 @@ test_expect_success $PREREQ 'Show all headers' '
291292
--dry-run \
292293
--suppress-cc=sob \
293294
--from="Example <[email protected]>" \
295+
--reply-to="Reply <[email protected]>" \
294296
295297
296298

0 commit comments

Comments
 (0)