{"thread":{"id":"23002","subject":"[PATCH] git-send-email.perl: improve error message in send_message()","startedAt":"2010-03-12T20:07:22Z","lastAt":"2010-03-12T23:04:39Z","messageCount":3,"participants":["Jari Aalto"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"136684","messageId":"87vdd1ti9f.fsf@jondo.cante.net","threadId":"23002","inReplyTo":null,"subject":"[PATCH] git-send-email.perl: improve error message in send_message()","fromName":"Jari Aalto","fromEmail":"jari.aalto@cante.net","sentAt":"2010-03-12T20:07:22Z","receivedAt":"2010-03-12T20:07:22Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"\n\nSigned-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n git-send-email.perl |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex e05455f..221506c 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -957,7 +957,10 @@ X-Mailer: git-send-email $gitversion\n \t\t}\n \n \t\tif (!$smtp) {\n-\t\t\tdie \"Unable to initialize SMTP properly.  Is there something wrong with your config?\";\n+\t\t\tdie \"Unable to initialize SMTP properly. Check config. \",\n+\t\t\t    \"VALUES: server=$smtp_server \",\n+\t\t\t    \"encryption=$smtp_encryption \",\n+\t\t\t    defined $smtp_server_port ? \"port=$smtp_server_port\" : \"\";\n \t\t}\n \n \t\tif (defined $smtp_authuser) {\n-- \n1.7.0\n"},{"id":"136688","messageId":"87r5nptdfh.fsf@jondo.cante.net","threadId":"23002","inReplyTo":"87vdd1ti9f.fsf@jondo.cante.net","subject":"[PATCH] git-send-email.perl: add option --smtp-debug","fromName":"Jari Aalto","fromEmail":"jari.aalto@cante.net","sentAt":"2010-03-12T21:53:06Z","receivedAt":"2010-03-12T21:53:06Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"Signed-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n git-send-email.perl |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\nThis patch makes it possible to see what's really going on instead of\nreading a cryptic message like \"Unable to initialize SMTP properly\".\n\nAn example:\n\n$ git send-email --smtp-debug 1  ...\n\nNet::SMTP>>> Net::SMTP(2.31)\nNet::SMTP>>>   Net::Cmd(2.29)\nNet::SMTP>>>     Exporter(5.63)\nNet::SMTP>>>   IO::Socket::INET(1.31)\nNet::SMTP>>>     IO::Socket(1.31)\nNet::SMTP>>>       IO::Handle(1.28)\nNet::SMTP=GLOB(0x267ec28)<<< 220 picasso.cante.net ESMTP Exim 4.71 Fri, 12 Mar 2010 23:49:15 +0200\nNet::SMTP=GLOB(0x267ec28)>>> EHLO localhost.localdomain\nNet::SMTP=GLOB(0x267ec28)<<< 550 EHLO argument does not match calling host\nNet::SMTP=GLOB(0x267ec28)>>> HELO localhost.localdomain\nNet::SMTP=GLOB(0x267ec28)<<< 550 HELO argument does not match calling host\n\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 221506c..6af7bd3 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -64,6 +64,7 @@ git send-email [options] <file | directory | rev-list options >\n     --smtp-pass             <str>  * Password for SMTP-AUTH; not necessary.\n     --smtp-encryption       <str>  * tls or ssl; anything else disables.\n     --smtp-ssl                     * Deprecated. Use '--smtp-encryption ssl'.\n+    --smtp-debug            <0|1>  * Disable, enable Net::SMTP debug.\n \n   Automating:\n     --identity              <str>  * Use the sendemail.<id> options.\n@@ -187,6 +188,8 @@ my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);\n my ($validate, $confirm);\n my (@suppress_cc);\n \n+my ($debug_net_smtp) = 0;\t\t# Net::SMTP, see send_message()\n+\n my $not_set_by_user = \"true but not set by the user\";\n \n my %config_bool_settings = (\n@@ -270,6 +273,7 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n \t\t    \"smtp-pass:s\" => \\$smtp_authpass,\n \t\t    \"smtp-ssl\" => sub { $smtp_encryption = 'ssl' },\n \t\t    \"smtp-encryption=s\" => \\$smtp_encryption,\n+\t\t    \"smtp-debug:i\" => \\$debug_net_smtp,\n \t\t    \"identity=s\" => \\$identity,\n \t\t    \"annotate\" => \\$annotate,\n \t\t    \"compose\" => \\$compose,\n@@ -938,7 +942,8 @@ X-Mailer: git-send-email $gitversion\n \t\t\trequire Net::SMTP;\n \t\t\t$smtp ||= Net::SMTP->new((defined $smtp_server_port)\n \t\t\t\t\t\t ? \"$smtp_server:$smtp_server_port\"\n-\t\t\t\t\t\t : $smtp_server);\n+\t\t\t\t\t\t : $smtp_server,\n+\t\t\t\t\t\t Debug => $debug_net_smtp);\n \t\t\tif ($smtp_encryption eq 'tls' && $smtp) {\n \t\t\t\trequire Net::SMTP::SSL;\n \t\t\t\t$smtp->command('STARTTLS');\n-- \n1.7.0\n"},{"id":"136689","messageId":"87hbolta48.fsf_-_@jondo.cante.net","threadId":"23002","inReplyTo":"87r5nptdfh.fsf@jondo.cante.net","subject":"[PATCH] git-send-email.perl - Fix 550 EHLO argument does not match calling host","fromName":"Jari Aalto","fromEmail":"jari.aalto@cante.net","sentAt":"2010-03-12T23:04:39Z","receivedAt":"2010-03-12T23:04:39Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"Add new function maildomain() which returns FQDN for use in\nsend_message(). The value is passed to Net::SMTP HELO/EHLO handshake.\n\nThe default value in Net::SMTP may not get through:\n\n  Net::SMTP=GLOB(0x267ec28)>>> EHLO localhost.localdomain\n  Net::SMTP=GLOB(0x267ec28)<<< 550 EHLO argument does not match calling host\n\nwhereas using the FQDN, the result is:\n\n  Net::SMTP=GLOB(0x15b8e80)>>> EHLO host.example.com\n  Net::SMTP=GLOB(0x15b8e80)<<< 250-host.example.com Hello host.example.com [192.168.1.7]\n\nSigned-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n git-send-email.perl |   52 +++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 50 insertions(+), 2 deletions(-)\n\n\nThis patch is applied *after* the other 2 sent in this thread.\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 6af7bd3..2eabed6 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -834,6 +834,46 @@ sub sanitize_address\n \n }\n \n+# Returns the local Fully Qualified Domain Name (FQDN) if available,\n+# If this is not given to EHLO, the receiving SMTP may deny connection\n+# Here is an example of Net::SMTP without explicit Helo: it\n+# uses by default \"localhost.localdomain\"\n+#\n+# Net::SMTP=GLOB(0x267ec28)>>> EHLO localhost.localdomain\n+# Net::SMTP=GLOB(0x267ec28)<<< 550 EHLO argument does not match calling host\n+\n+sub maildomain ()\n+{\n+\tmy $maildomain;\n+\teval \"use Net::Domain\";\n+\n+\tunless ( $@ ) {\n+\t\tfor my $host ( qw(mailhost localhost) ) {\n+\t\t\tmy $smtp = Net::SMTP->new($host);\n+\t\t\tif (defined $smtp) {\n+\t\t\t\tmy $domain = $smtp->domain;\n+\t\t\t\t$smtp->quit;\n+\n+\t\t\t\t$maildomain = $domain\n+\t\t\t\t\tunless $^O eq 'darwin' && $domain =~ /\\.local$/;\n+\n+\t\t\t\tlast if $maildomain;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\tunless ($maildomain) {\n+\t\teval \"use Net::Domain\";\n+\t\tunless ( $@ ) {\n+\t\t    my $domain = Net::Domain::domainname();\n+\t\t    $maildomain = $domain\n+\t\t\t    unless $^O eq 'darwin' && $domain =~ /\\.local$/;\n+\t\t}\n+\t}\n+\n+\t$maildomain;\n+}\n+\n # Returns 1 if the message was sent, and 0 otherwise.\n # In actuality, the whole program dies when there\n # is an error sending a message.\n@@ -917,6 +957,8 @@ X-Mailer: git-send-email $gitversion\n \t\t}\n \t}\n \n+\tmy $maildomain;\n+\n \tif ($dry_run) {\n \t\t# We don't want to send the email.\n \t} elsif ($smtp_server =~ m#^/#) {\n@@ -936,13 +978,18 @@ X-Mailer: git-send-email $gitversion\n \t\tif ($smtp_encryption eq 'ssl') {\n \t\t\t$smtp_server_port ||= 465; # ssmtp\n \t\t\trequire Net::SMTP::SSL;\n-\t\t\t$smtp ||= Net::SMTP::SSL->new($smtp_server, Port => $smtp_server_port);\n+\t\t\t$maildomain = maildomain() || \"localhost.localdomain\";\n+\t\t\t$smtp ||= Net::SMTP::SSL->new($smtp_server,\n+\t\t\t\t\t\t      Hello => $maildomain,\n+\t\t\t\t\t\t      Port => $smtp_server_port);\n \t\t}\n \t\telse {\n \t\t\trequire Net::SMTP;\n+\t\t\t$maildomain = maildomain() || \"localhost.localdomain\";\n \t\t\t$smtp ||= Net::SMTP->new((defined $smtp_server_port)\n \t\t\t\t\t\t ? \"$smtp_server:$smtp_server_port\"\n \t\t\t\t\t\t : $smtp_server,\n+\t\t\t\t\t\t Hello => $maildomain,\n \t\t\t\t\t\t Debug => $debug_net_smtp);\n \t\t\tif ($smtp_encryption eq 'tls' && $smtp) {\n \t\t\t\trequire Net::SMTP::SSL;\n@@ -962,9 +1009,10 @@ X-Mailer: git-send-email $gitversion\n \t\t}\n \n \t\tif (!$smtp) {\n-\t\t\tdie \"Unable to initialize SMTP properly. Check config. \",\n+\t\t\tdie \"Unable to initialize SMTP properly. Check config and use --smtp-debug. \",\n \t\t\t    \"VALUES: server=$smtp_server \",\n \t\t\t    \"encryption=$smtp_encryption \",\n+\t\t\t    \"maildomain=$maildomain\",\n \t\t\t    defined $smtp_server_port ? \"port=$smtp_server_port\" : \"\";\n \t\t}\n \n-- \n1.7.0\n"}]}