Skip to content

Commit 69cf7bf

Browse files
Benabikgitster
authored andcommitted
send-email: Cleanup smtp-domain and add config
The way the code stored --smtp-domain was unlike its handling of other similar options. Bring it in line with the others by: - Renaming $mail_domain to $smtp_domain to match the command line option. Also move its declaration from near the top of the file to near other option variables. - Removing $mail_domain_default. The variable was used once and only served to move the default away from where it gets used. - Adding a sendemail.smtpdomain config option. smtp-domain was the only SMTP configuration option that couldn't be set in the user's .gitconfig. Signed-off-by: Brian Gernhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 79ca070 commit 69cf7bf

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

Documentation/config.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,7 @@ sendemail.smtppass::
15731573
sendemail.suppresscc::
15741574
sendemail.suppressfrom::
15751575
sendemail.to::
1576+
sendemail.smtpdomain::
15761577
sendemail.smtpserver::
15771578
sendemail.smtpserverport::
15781579
sendemail.smtpuser::

Documentation/git-send-email.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ Sending
123123
Specifies the Fully Qualified Domain Name (FQDN) used in the
124124
HELO/EHLO command to the SMTP server. Some servers require the
125125
FQDN to match your IP address. If not set, git send-email attempts
126-
to determine your FQDN automatically.
126+
to determine your FQDN automatically. Default is the value of
127+
'sendemail.smtpdomain'.
127128

128129
--smtp-pass[=<password>]::
129130
Password for SMTP-AUTH. The argument is optional: If no

git-send-email.perl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ sub format_2822_time {
132132
my $have_mail_address = eval { require Mail::Address; 1 };
133133
my $smtp;
134134
my $auth;
135-
my $mail_domain_default = "localhost.localdomain";
136-
my $mail_domain;
137135

138136
sub unique_email_list(@);
139137
sub cleanup_compose_files();
@@ -187,7 +185,7 @@ sub do_edit {
187185
# Variables with corresponding config settings
188186
my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
189187
my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);
190-
my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
188+
my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain);
191189
my ($validate, $confirm);
192190
my (@suppress_cc);
193191

@@ -209,6 +207,7 @@ sub do_edit {
209207
"smtpserverport" => \$smtp_server_port,
210208
"smtpuser" => \$smtp_authuser,
211209
"smtppass" => \$smtp_authpass,
210+
"smtpdomain" => \$smtp_domain,
212211
"to" => \@to,
213212
"cc" => \@initial_cc,
214213
"cccmd" => \$cc_cmd,
@@ -277,7 +276,7 @@ sub signal_handler {
277276
"smtp-ssl" => sub { $smtp_encryption = 'ssl' },
278277
"smtp-encryption=s" => \$smtp_encryption,
279278
"smtp-debug:i" => \$debug_net_smtp,
280-
"smtp-domain:s" => \$mail_domain,
279+
"smtp-domain:s" => \$smtp_domain,
281280
"identity=s" => \$identity,
282281
"annotate" => \$annotate,
283282
"compose" => \$compose,
@@ -889,7 +888,7 @@ sub maildomain_mta {
889888
}
890889

891890
sub maildomain {
892-
return maildomain_net() || maildomain_mta() || $mail_domain_default;
891+
return maildomain_net() || maildomain_mta() || 'localhost.localdomain';
893892
}
894893

895894
# Returns 1 if the message was sent, and 0 otherwise.
@@ -993,18 +992,18 @@ sub send_message {
993992
if ($smtp_encryption eq 'ssl') {
994993
$smtp_server_port ||= 465; # ssmtp
995994
require Net::SMTP::SSL;
996-
$mail_domain ||= maildomain();
995+
$smtp_domain ||= maildomain();
997996
$smtp ||= Net::SMTP::SSL->new($smtp_server,
998-
Hello => $mail_domain,
997+
Hello => $smtp_domain,
999998
Port => $smtp_server_port);
1000999
}
10011000
else {
10021001
require Net::SMTP;
1003-
$mail_domain ||= maildomain();
1002+
$smtp_domain ||= maildomain();
10041003
$smtp ||= Net::SMTP->new((defined $smtp_server_port)
10051004
? "$smtp_server:$smtp_server_port"
10061005
: $smtp_server,
1007-
Hello => $mail_domain,
1006+
Hello => $smtp_domain,
10081007
Debug => $debug_net_smtp);
10091008
if ($smtp_encryption eq 'tls' && $smtp) {
10101009
require Net::SMTP::SSL;
@@ -1027,7 +1026,7 @@ sub send_message {
10271026
die "Unable to initialize SMTP properly. Check config and use --smtp-debug. ",
10281027
"VALUES: server=$smtp_server ",
10291028
"encryption=$smtp_encryption ",
1030-
"maildomain=$mail_domain",
1029+
"hello=$smtp_domain",
10311030
defined $smtp_server_port ? "port=$smtp_server_port" : "";
10321031
}
10331032

0 commit comments

Comments
 (0)