* [PATCH] git-send-email.perl: improve error message in send_message()
@ 2010-03-12 20:07 Jari Aalto
2010-03-12 21:53 ` [PATCH] git-send-email.perl: add option --smtp-debug Jari Aalto
0 siblings, 1 reply; 3+ messages in thread
From: Jari Aalto @ 2010-03-12 20:07 UTC (permalink / raw
To: git
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
git-send-email.perl | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index e05455f..221506c 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -957,7 +957,10 @@ X-Mailer: git-send-email $gitversion
}
if (!$smtp) {
- die "Unable to initialize SMTP properly. Is there something wrong with your config?";
+ die "Unable to initialize SMTP properly. Check config. ",
+ "VALUES: server=$smtp_server ",
+ "encryption=$smtp_encryption ",
+ defined $smtp_server_port ? "port=$smtp_server_port" : "";
}
if (defined $smtp_authuser) {
--
1.7.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] git-send-email.perl: add option --smtp-debug
2010-03-12 20:07 [PATCH] git-send-email.perl: improve error message in send_message() Jari Aalto
@ 2010-03-12 21:53 ` Jari Aalto
2010-03-12 23:04 ` [PATCH] git-send-email.perl - Fix 550 EHLO argument does not match calling host Jari Aalto
0 siblings, 1 reply; 3+ messages in thread
From: Jari Aalto @ 2010-03-12 21:53 UTC (permalink / raw
To: git
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
git-send-email.perl | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
This patch makes it possible to see what's really going on instead of
reading a cryptic message like "Unable to initialize SMTP properly".
An example:
$ git send-email --smtp-debug 1 ...
Net::SMTP>>> Net::SMTP(2.31)
Net::SMTP>>> Net::Cmd(2.29)
Net::SMTP>>> Exporter(5.63)
Net::SMTP>>> IO::Socket::INET(1.31)
Net::SMTP>>> IO::Socket(1.31)
Net::SMTP>>> IO::Handle(1.28)
Net::SMTP=GLOB(0x267ec28)<<< 220 picasso.cante.net ESMTP Exim 4.71 Fri, 12 Mar 2010 23:49:15 +0200
Net::SMTP=GLOB(0x267ec28)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x267ec28)<<< 550 EHLO argument does not match calling host
Net::SMTP=GLOB(0x267ec28)>>> HELO localhost.localdomain
Net::SMTP=GLOB(0x267ec28)<<< 550 HELO argument does not match calling host
diff --git a/git-send-email.perl b/git-send-email.perl
index 221506c..6af7bd3 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -64,6 +64,7 @@ git send-email [options] <file | directory | rev-list options >
--smtp-pass <str> * Password for SMTP-AUTH; not necessary.
--smtp-encryption <str> * tls or ssl; anything else disables.
--smtp-ssl * Deprecated. Use '--smtp-encryption ssl'.
+ --smtp-debug <0|1> * Disable, enable Net::SMTP debug.
Automating:
--identity <str> * Use the sendemail.<id> options.
@@ -187,6 +188,8 @@ my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
my ($validate, $confirm);
my (@suppress_cc);
+my ($debug_net_smtp) = 0; # Net::SMTP, see send_message()
+
my $not_set_by_user = "true but not set by the user";
my %config_bool_settings = (
@@ -270,6 +273,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
"smtp-pass:s" => \$smtp_authpass,
"smtp-ssl" => sub { $smtp_encryption = 'ssl' },
"smtp-encryption=s" => \$smtp_encryption,
+ "smtp-debug:i" => \$debug_net_smtp,
"identity=s" => \$identity,
"annotate" => \$annotate,
"compose" => \$compose,
@@ -938,7 +942,8 @@ X-Mailer: git-send-email $gitversion
require Net::SMTP;
$smtp ||= Net::SMTP->new((defined $smtp_server_port)
? "$smtp_server:$smtp_server_port"
- : $smtp_server);
+ : $smtp_server,
+ Debug => $debug_net_smtp);
if ($smtp_encryption eq 'tls' && $smtp) {
require Net::SMTP::SSL;
$smtp->command('STARTTLS');
--
1.7.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] git-send-email.perl - Fix 550 EHLO argument does not match calling host
2010-03-12 21:53 ` [PATCH] git-send-email.perl: add option --smtp-debug Jari Aalto
@ 2010-03-12 23:04 ` Jari Aalto
0 siblings, 0 replies; 3+ messages in thread
From: Jari Aalto @ 2010-03-12 23:04 UTC (permalink / raw
To: git
Add new function maildomain() which returns FQDN for use in
send_message(). The value is passed to Net::SMTP HELO/EHLO handshake.
The default value in Net::SMTP may not get through:
Net::SMTP=GLOB(0x267ec28)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x267ec28)<<< 550 EHLO argument does not match calling host
whereas using the FQDN, the result is:
Net::SMTP=GLOB(0x15b8e80)>>> EHLO host.example.com
Net::SMTP=GLOB(0x15b8e80)<<< 250-host.example.com Hello host.example.com [192.168.1.7]
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
git-send-email.perl | 52 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 50 insertions(+), 2 deletions(-)
This patch is applied *after* the other 2 sent in this thread.
diff --git a/git-send-email.perl b/git-send-email.perl
index 6af7bd3..2eabed6 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -834,6 +834,46 @@ sub sanitize_address
}
+# Returns the local Fully Qualified Domain Name (FQDN) if available,
+# If this is not given to EHLO, the receiving SMTP may deny connection
+# Here is an example of Net::SMTP without explicit Helo: it
+# uses by default "localhost.localdomain"
+#
+# Net::SMTP=GLOB(0x267ec28)>>> EHLO localhost.localdomain
+# Net::SMTP=GLOB(0x267ec28)<<< 550 EHLO argument does not match calling host
+
+sub maildomain ()
+{
+ my $maildomain;
+ eval "use Net::Domain";
+
+ unless ( $@ ) {
+ for my $host ( qw(mailhost localhost) ) {
+ my $smtp = Net::SMTP->new($host);
+ if (defined $smtp) {
+ my $domain = $smtp->domain;
+ $smtp->quit;
+
+ $maildomain = $domain
+ unless $^O eq 'darwin' && $domain =~ /\.local$/;
+
+ last if $maildomain;
+ }
+ }
+ }
+
+ unless ($maildomain) {
+ eval "use Net::Domain";
+ unless ( $@ ) {
+ my $domain = Net::Domain::domainname();
+ $maildomain = $domain
+ unless $^O eq 'darwin' && $domain =~ /\.local$/;
+ }
+ }
+
+ $maildomain;
+}
+
# Returns 1 if the message was sent, and 0 otherwise.
# In actuality, the whole program dies when there
# is an error sending a message.
@@ -917,6 +957,8 @@ X-Mailer: git-send-email $gitversion
}
}
+ my $maildomain;
+
if ($dry_run) {
# We don't want to send the email.
} elsif ($smtp_server =~ m#^/#) {
@@ -936,13 +978,18 @@ X-Mailer: git-send-email $gitversion
if ($smtp_encryption eq 'ssl') {
$smtp_server_port ||= 465; # ssmtp
require Net::SMTP::SSL;
- $smtp ||= Net::SMTP::SSL->new($smtp_server, Port => $smtp_server_port);
+ $maildomain = maildomain() || "localhost.localdomain";
+ $smtp ||= Net::SMTP::SSL->new($smtp_server,
+ Hello => $maildomain,
+ Port => $smtp_server_port);
}
else {
require Net::SMTP;
+ $maildomain = maildomain() || "localhost.localdomain";
$smtp ||= Net::SMTP->new((defined $smtp_server_port)
? "$smtp_server:$smtp_server_port"
: $smtp_server,
+ Hello => $maildomain,
Debug => $debug_net_smtp);
if ($smtp_encryption eq 'tls' && $smtp) {
require Net::SMTP::SSL;
@@ -962,9 +1009,10 @@ X-Mailer: git-send-email $gitversion
}
if (!$smtp) {
- die "Unable to initialize SMTP properly. Check config. ",
+ die "Unable to initialize SMTP properly. Check config and use --smtp-debug. ",
"VALUES: server=$smtp_server ",
"encryption=$smtp_encryption ",
+ "maildomain=$maildomain",
defined $smtp_server_port ? "port=$smtp_server_port" : "";
}
--
1.7.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-12 23:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-12 20:07 [PATCH] git-send-email.perl: improve error message in send_message() Jari Aalto
2010-03-12 21:53 ` [PATCH] git-send-email.perl: add option --smtp-debug Jari Aalto
2010-03-12 23:04 ` [PATCH] git-send-email.perl - Fix 550 EHLO argument does not match calling host Jari Aalto
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).