* [PATCH v3 0/4] send-email: --smtp-domain improvements
@ 2010-04-10 14:53 Brian Gernhardt
2010-04-10 14:53 ` [PATCH v3 1/4] send-email: Cleanup { style Brian Gernhardt
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Brian Gernhardt @ 2010-04-10 14:53 UTC (permalink / raw)
To: Git List; +Cc: Jakub Narebski, Junio C Hamano
Next iteration of my small series of fixes to --smtp-domain.
Changes since v2:
1/4: Added a patch that standardizes on a single bracket style for subs.
2/4: Fixed the style of valid_fqdn() and calls to it.
4/4: Remove default variable and significantly improve commit message.
Many thanks to Jakub Narebski for his repeated suggestions.
Brian Gernhardt (4):
send-email: Cleanup { style
send-email: Don't use FQDNs without a '.'
Document send-email --smtp-domain
send-email: Cleanup smtp-domain and add config
Documentation/config.txt | 1 +
Documentation/git-send-email.txt | 7 +++++
git-send-email.perl | 48 +++++++++++++++++--------------------
3 files changed, 30 insertions(+), 26 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/4] send-email: Cleanup { style
2010-04-10 14:53 [PATCH v3 0/4] send-email: --smtp-domain improvements Brian Gernhardt
@ 2010-04-10 14:53 ` Brian Gernhardt
2010-04-10 20:02 ` Junio C Hamano
2010-04-10 14:53 ` [PATCH v3 2/4] send-email: Don't use FQDNs without a '.' Brian Gernhardt
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Brian Gernhardt @ 2010-04-10 14:53 UTC (permalink / raw)
To: Git List; +Cc: Jakub Narebski, Junio C Hamano
As Jakub Narebski pointed out on the list, Perl code usually prefers
sub func {
}
over
sub func
{
}
git-send-email.perl is somewhat inconsistent in its style, with 23
subroutines using the first style and 6 using the second. Convert the
few odd subroutines so that the code matches normal Perl style.
Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
---
git-send-email.perl | 18 ++++++------------
1 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index ce569a9..26fe624 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -761,8 +761,7 @@ sub extract_valid_address {
# We'll setup a template for the message id, using the "from" address:
my ($message_id_stamp, $message_id_serial);
-sub make_message_id
-{
+sub make_message_id {
my $uniq;
if (!defined $message_id_stamp) {
$message_id_stamp = sprintf("%s-%s", time, $$);
@@ -817,8 +816,7 @@ sub is_rfc2047_quoted {
}
# use the simplest quoting being able to handle the recipient
-sub sanitize_address
-{
+sub sanitize_address {
my ($recipient) = @_;
my ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)\s*(<.*)/);
@@ -863,8 +861,7 @@ sub sanitize_address
# This maildomain*() code is based on ideas in Perl library Test::Reporter
# /usr/share/perl5/Test/Reporter/Mail/Util.pm ==> sub _maildomain ()
-sub maildomain_net
-{
+sub maildomain_net {
my $maildomain;
if (eval { require Net::Domain; 1 }) {
@@ -876,8 +873,7 @@ sub maildomain_net
return $maildomain;
}
-sub maildomain_mta
-{
+sub maildomain_mta {
my $maildomain;
if (eval { require Net::SMTP; 1 }) {
@@ -898,8 +894,7 @@ sub maildomain_mta
return $maildomain;
}
-sub maildomain
-{
+sub maildomain {
return maildomain_net() || maildomain_mta() || $mail_domain_default;
}
@@ -907,8 +902,7 @@ sub maildomain
# In actuality, the whole program dies when there
# is an error sending a message.
-sub send_message
-{
+sub send_message {
my @recipients = unique_email_list(@to);
@cc = (grep { my $cc = extract_valid_address($_);
not grep { $cc eq $_ } @recipients
--
1.7.1.rc0.251.g42f41
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/4] send-email: Don't use FQDNs without a '.'
2010-04-10 14:53 [PATCH v3 0/4] send-email: --smtp-domain improvements Brian Gernhardt
2010-04-10 14:53 ` [PATCH v3 1/4] send-email: Cleanup { style Brian Gernhardt
@ 2010-04-10 14:53 ` Brian Gernhardt
2010-04-10 14:53 ` [PATCH v3 3/4] Document send-email --smtp-domain Brian Gernhardt
2010-04-10 14:53 ` [PATCH v3 4/4] send-email: Cleanup smtp-domain and add config Brian Gernhardt
3 siblings, 0 replies; 6+ messages in thread
From: Brian Gernhardt @ 2010-04-10 14:53 UTC (permalink / raw)
To: Git List; +Cc: Jakub Narebski, Junio C Hamano
Although Net::Domain::domainname attempts to be very thorough, the
host's configuration can still refuse to give a FQDN. Check to see if
what we receive contains a dot as a basic sanity check.
Since the same condition is used twice and getting complex, let's move
it to a new function.
Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
---
git-send-email.perl | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 26fe624..1e9bec1 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -861,13 +861,17 @@ sub sanitize_address {
# This maildomain*() code is based on ideas in Perl library Test::Reporter
# /usr/share/perl5/Test/Reporter/Mail/Util.pm ==> sub _maildomain ()
+sub valid_fqdn {
+ my $domain = shift;
+ return !($^O eq 'darwin' && $domain =~ /\.local$/) && $domain =~ /\./;
+}
+
sub maildomain_net {
my $maildomain;
if (eval { require Net::Domain; 1 }) {
my $domain = Net::Domain::domainname();
- $maildomain = $domain
- unless $^O eq 'darwin' && $domain =~ /\.local$/;
+ $maildomain = $domain if valid_fqdn($domain);
}
return $maildomain;
@@ -883,8 +887,7 @@ sub maildomain_mta {
my $domain = $smtp->domain;
$smtp->quit;
- $maildomain = $domain
- unless $^O eq 'darwin' && $domain =~ /\.local$/;
+ $maildomain = $domain if valid_fqdn($domain);
last if $maildomain;
}
--
1.7.1.rc0.251.g42f41
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 3/4] Document send-email --smtp-domain
2010-04-10 14:53 [PATCH v3 0/4] send-email: --smtp-domain improvements Brian Gernhardt
2010-04-10 14:53 ` [PATCH v3 1/4] send-email: Cleanup { style Brian Gernhardt
2010-04-10 14:53 ` [PATCH v3 2/4] send-email: Don't use FQDNs without a '.' Brian Gernhardt
@ 2010-04-10 14:53 ` Brian Gernhardt
2010-04-10 14:53 ` [PATCH v3 4/4] send-email: Cleanup smtp-domain and add config Brian Gernhardt
3 siblings, 0 replies; 6+ messages in thread
From: Brian Gernhardt @ 2010-04-10 14:53 UTC (permalink / raw)
To: Git List; +Cc: Jakub Narebski, Junio C Hamano
Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
---
Documentation/git-send-email.txt | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index ced35b2..f171471 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -119,6 +119,12 @@ Sending
value reverts to plain SMTP. Default is the value of
'sendemail.smtpencryption'.
+--smtp-domain=<FQDN>::
+ Specifies the Fully Qualified Domain Name (FQDN) used in the
+ HELO/EHLO command to the SMTP server. Some servers require the
+ FQDN to match your IP address. If not set, git send-email attempts
+ to determine your FQDN automatically.
+
--smtp-pass[=<password>]::
Password for SMTP-AUTH. The argument is optional: If no
argument is specified, then the empty string is used as
--
1.7.1.rc0.251.g42f41
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 4/4] send-email: Cleanup smtp-domain and add config
2010-04-10 14:53 [PATCH v3 0/4] send-email: --smtp-domain improvements Brian Gernhardt
` (2 preceding siblings ...)
2010-04-10 14:53 ` [PATCH v3 3/4] Document send-email --smtp-domain Brian Gernhardt
@ 2010-04-10 14:53 ` Brian Gernhardt
3 siblings, 0 replies; 6+ messages in thread
From: Brian Gernhardt @ 2010-04-10 14:53 UTC (permalink / raw)
To: Git List; +Cc: Jakub Narebski, Junio C Hamano
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>
---
Documentation/config.txt | 1 +
Documentation/git-send-email.txt | 3 ++-
git-send-email.perl | 19 +++++++++----------
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 626b19a..b755beb 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1651,6 +1651,7 @@ sendemail.smtppass::
sendemail.suppresscc::
sendemail.suppressfrom::
sendemail.to::
+sendemail.smtpdomain::
sendemail.smtpserver::
sendemail.smtpserverport::
sendemail.smtpuser::
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index f171471..288a4ec 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -123,7 +123,8 @@ Sending
Specifies the Fully Qualified Domain Name (FQDN) used in the
HELO/EHLO command to the SMTP server. Some servers require the
FQDN to match your IP address. If not set, git send-email attempts
- to determine your FQDN automatically.
+ to determine your FQDN automatically. Default is the value of
+ 'sendemail.smtpdomain'.
--smtp-pass[=<password>]::
Password for SMTP-AUTH. The argument is optional: If no
diff --git a/git-send-email.perl b/git-send-email.perl
index 1e9bec1..111c981 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -132,8 +132,6 @@ my $have_email_valid = eval { require Email::Valid; 1 };
my $have_mail_address = eval { require Mail::Address; 1 };
my $smtp;
my $auth;
-my $mail_domain_default = "localhost.localdomain";
-my $mail_domain;
sub unique_email_list(@);
sub cleanup_compose_files();
@@ -190,7 +188,7 @@ sub do_edit {
# Variables with corresponding config settings
my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);
-my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
+my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain);
my ($validate, $confirm);
my (@suppress_cc);
@@ -212,6 +210,7 @@ my %config_settings = (
"smtpserverport" => \$smtp_server_port,
"smtpuser" => \$smtp_authuser,
"smtppass" => \$smtp_authpass,
+ "smtpdomain" => \$smtp_domain,
"to" => \@to,
"cc" => \@initial_cc,
"cccmd" => \$cc_cmd,
@@ -283,7 +282,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
"smtp-ssl" => sub { $smtp_encryption = 'ssl' },
"smtp-encryption=s" => \$smtp_encryption,
"smtp-debug:i" => \$debug_net_smtp,
- "smtp-domain:s" => \$mail_domain,
+ "smtp-domain:s" => \$smtp_domain,
"identity=s" => \$identity,
"annotate" => \$annotate,
"compose" => \$compose,
@@ -898,7 +897,7 @@ sub maildomain_mta {
}
sub maildomain {
- return maildomain_net() || maildomain_mta() || $mail_domain_default;
+ return maildomain_net() || maildomain_mta() || 'localhost.localdomain';
}
# Returns 1 if the message was sent, and 0 otherwise.
@@ -1002,18 +1001,18 @@ X-Mailer: git-send-email $gitversion
if ($smtp_encryption eq 'ssl') {
$smtp_server_port ||= 465; # ssmtp
require Net::SMTP::SSL;
- $mail_domain ||= maildomain();
+ $smtp_domain ||= maildomain();
$smtp ||= Net::SMTP::SSL->new($smtp_server,
- Hello => $mail_domain,
+ Hello => $smtp_domain,
Port => $smtp_server_port);
}
else {
require Net::SMTP;
- $mail_domain ||= maildomain();
+ $smtp_domain ||= maildomain();
$smtp ||= Net::SMTP->new((defined $smtp_server_port)
? "$smtp_server:$smtp_server_port"
: $smtp_server,
- Hello => $mail_domain,
+ Hello => $smtp_domain,
Debug => $debug_net_smtp);
if ($smtp_encryption eq 'tls' && $smtp) {
require Net::SMTP::SSL;
@@ -1036,7 +1035,7 @@ X-Mailer: git-send-email $gitversion
die "Unable to initialize SMTP properly. Check config and use --smtp-debug. ",
"VALUES: server=$smtp_server ",
"encryption=$smtp_encryption ",
- "maildomain=$mail_domain",
+ "hello=$smtp_domain",
defined $smtp_server_port ? "port=$smtp_server_port" : "";
}
--
1.7.1.rc0.251.g42f41
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/4] send-email: Cleanup { style
2010-04-10 14:53 ` [PATCH v3 1/4] send-email: Cleanup { style Brian Gernhardt
@ 2010-04-10 20:02 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2010-04-10 20:02 UTC (permalink / raw)
To: Brian Gernhardt; +Cc: Git List, Jakub Narebski
Thanks; will queue all four of them.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-04-10 20:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-10 14:53 [PATCH v3 0/4] send-email: --smtp-domain improvements Brian Gernhardt
2010-04-10 14:53 ` [PATCH v3 1/4] send-email: Cleanup { style Brian Gernhardt
2010-04-10 20:02 ` Junio C Hamano
2010-04-10 14:53 ` [PATCH v3 2/4] send-email: Don't use FQDNs without a '.' Brian Gernhardt
2010-04-10 14:53 ` [PATCH v3 3/4] Document send-email --smtp-domain Brian Gernhardt
2010-04-10 14:53 ` [PATCH v3 4/4] send-email: Cleanup smtp-domain and add config Brian Gernhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).