@matheusbsbs / matheus-bagliano / commits / 69cf7bfd13
Fork 0

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

Brian Gernhardt committed Apr 10, 2010 at 10:53 UTC 69cf7bfd131ae6246931459a1e6513d51f0b0119
3 files changed +12 -11
Documentation/config.txt
+1
@@ -1573,6 +1573,7 @@ sendemail.smtppass::
1573 sendemail.suppresscc::
1574 sendemail.suppressfrom::
1575 sendemail.to::
1576 +sendemail.smtpdomain::
1577 sendemail.smtpserver::
1578 sendemail.smtpserverport::
1579 sendemail.smtpuser::
Documentation/git-send-email.txt
+2 -1
@@ -123,7 +123,8 @@ Sending
123 Specifies the Fully Qualified Domain Name (FQDN) used in the
124 HELO/EHLO command to the SMTP server. Some servers require the
125 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'.
128
129 --smtp-pass[=<password>]::
130 Password for SMTP-AUTH. The argument is optional: If no
git-send-email.perl
+9 -10
@@ -132,8 +132,6 @@ my $have_email_valid = eval { require Email::Valid; 1 };
132 my $have_mail_address = eval { require Mail::Address; 1 };
133 my $smtp;
134 my $auth;
135 -my $mail_domain_default = "localhost.localdomain";
136 -my $mail_domain;
135
136 sub unique_email_list(@);
137 sub cleanup_compose_files();
@@ -187,7 +185,7 @@ sub do_edit {
185 # Variables with corresponding config settings
186 my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
187 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);
189 my ($validate, $confirm);
190 my (@suppress_cc);
191
@@ -209,6 +207,7 @@ my %config_settings = (
207 "smtpserverport" => \$smtp_server_port,
208 "smtpuser" => \$smtp_authuser,
209 "smtppass" => \$smtp_authpass,
210 + "smtpdomain" => \$smtp_domain,
211 "to" => \@to,
212 "cc" => \@initial_cc,
213 "cccmd" => \$cc_cmd,
@@ -277,7 +276,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
276 "smtp-ssl" => sub { $smtp_encryption = 'ssl' },
277 "smtp-encryption=s" => \$smtp_encryption,
278 "smtp-debug:i" => \$debug_net_smtp,
280 - "smtp-domain:s" => \$mail_domain,
279 + "smtp-domain:s" => \$smtp_domain,
280 "identity=s" => \$identity,
281 "annotate" => \$annotate,
282 "compose" => \$compose,
@@ -889,7 +888,7 @@ sub maildomain_mta {
888 }
889
890 sub maildomain {
892 - return maildomain_net() || maildomain_mta() || $mail_domain_default;
891 + return maildomain_net() || maildomain_mta() || 'localhost.localdomain';
892 }
893
894 # Returns 1 if the message was sent, and 0 otherwise.
@@ -993,18 +992,18 @@ X-Mailer: git-send-email $gitversion
992 if ($smtp_encryption eq 'ssl') {
993 $smtp_server_port ||= 465; # ssmtp
994 require Net::SMTP::SSL;
996 - $mail_domain ||= maildomain();
995 + $smtp_domain ||= maildomain();
996 $smtp ||= Net::SMTP::SSL->new($smtp_server,
998 - Hello => $mail_domain,
997 + Hello => $smtp_domain,
998 Port => $smtp_server_port);
999 }
1000 else {
1001 require Net::SMTP;
1003 - $mail_domain ||= maildomain();
1002 + $smtp_domain ||= maildomain();
1003 $smtp ||= Net::SMTP->new((defined $smtp_server_port)
1004 ? "$smtp_server:$smtp_server_port"
1005 : $smtp_server,
1007 - Hello => $mail_domain,
1006 + Hello => $smtp_domain,
1007 Debug => $debug_net_smtp);
1008 if ($smtp_encryption eq 'tls' && $smtp) {
1009 require Net::SMTP::SSL;
@@ -1027,7 +1026,7 @@ X-Mailer: git-send-email $gitversion
1026 die "Unable to initialize SMTP properly. Check config and use --smtp-debug. ",
1027 "VALUES: server=$smtp_server ",
1028 "encryption=$smtp_encryption ",
1030 - "maildomain=$mail_domain",
1029 + "hello=$smtp_domain",
1030 defined $smtp_server_port ? "port=$smtp_server_port" : "";
1031 }
1032