git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-send-email.perl - Fix 550 EHLO argument does not match calling host

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 14, 2010, 06:28 UTC
Message-ID
<7vtysjs9hi.fsf@alter.siamese.dyndns.org>
In-Reply-To
<87eijng4hy.fsf@jondo.cante.net>
Jari Aalto <jari.aalto@cante.net> writes:
Show 7 quoted lines
>>  - You are trying to improve the chance that $smtp_server likes the name
>>    your side identifies as; what does it have to do with your local
>>    "mailhost" or "localhost" listening to the SMTP port?  These local MTA
>>    may be configured for local-only delivery after all.
>
> There is now explicit option to set the name with option --mail-domain.
> Hope this address the issue.

Not quite. Imagine if you were a maintainer of a system who received a patch that looks like adding a piece of code that computes random rubbish.

    sub a_function () {
	compute some value that looked not so useful nor reliable;
        return it to be used;
    }

When you ask the contributor why the code computes and uses it, the contributor sends an updated patch that lets the user override the logic and specify the exact value to be used. That is:

    sub a_function () {
+	if (the user gave a value)
+        	return that value;
	compute some value that looked not so useful nor reliable;
        return it to be used;
    }
Does that updated patch answer the question you asked?

Configurability does not alleviate the puzzlement about the logic. A better explanation would be to describe how the computation produces reliable and correct value for the most sane installations; then the user configurability becomes only "just in case" way to give them the last resort.

If you don't have a good explanation, the patch should instead be like this:

    sub a_function () {
-	compute some value that looked not so useful nor reliable;
-       return it to be used;
+	if (the user gave a value)
+        	return that value;
+	die "please configure me";
    }

So please explain why asking your local MTA (either mailhost or localhost) how it is configured to identify to other MTA is a good way to obtain the HELO domain you should give $smtp_server. Your answer could be "I expect that most people use $smtp_server set to 'mailhost' or 'localhost' and have the MTA configured to talk with the outside world." (which by the way I do not think is true for most people). Or it could be "Xsmtp MTA that is used by many people to send out mails through their ISP's mailserver uses the same trick to solve this issue".

Side note. Apparently this seems to be a common issue. For example, msmtp has this configurable via command line and configuration option:

   domain argument
          Use  this  command to set the argument of the SMTP EHLO (or LMTP
          LHLO) command.  The default is localhost (stupid, but  working).
          Possible  choices  are  the  domain  part  of  your mail address
          (provider.example for joe@provider.example) or the fully  quali‐
          fied domain name of your host (if available).

Interestingly, one of the suggestions above is to derive it from the From address.

In any case, I want to hear your justification.
> +    --smtp-domain           <str>  * The domain name sent to HELO/EHLO handshake

I think this addition makes sense. I suspect that we would also want to have sendemail.smtpdomain configuration variable. They of course need to be documented.

Show 5 quoted lines
> @@ -131,6 +132,7 @@ 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;			# See maildomain()

Why uppercase? The lifetime rule for this looks exactly the same as existing $smtp to me, so it would be more sensible to spell it in lowercase, $mail_domain.

Show 5 quoted lines
> +sub maildomain
> +{
> +        return $MAIL_DOMAIN if $MAIL_DOMAIN;
> +
> +	my $maildomain;
Looks like a funny indent here...
> +	eval "use Net::SMTP";
> +
> +	unless ( $@ ) {
> +		for my $host ( qw(mailhost localhost) ) {

Please drop extra SP immediately after '(' and before ')'; they are distracting.

But as I already said, I tend to think the logic implemented by this part is of dubious validity.

Show 15 quoted lines
> @@ -917,6 +962,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 +983,18 @@ X-Mailer: git-send-email $gitversion
> ...
> +			$maildomain = maildomain() || "localhost.localdomain";
> +			$smtp ||= Net::SMTP::SSL->new($smtp_server,
> +						      Hello => $maildomain,
> +						      Port => $smtp_server_port);

Why not use the same structure as how lifetime is defined for $smtp variable? IOW,

			$mail_domain || = maildomain();
			$smtp ||= ...
without an extra local $maildomain variable?  If you do so, then
 - You can lose the $maildomain variable local to this function;
 - "return what the user configured" does not have to be in the maildomain
   sub;
 - the maildomain sub can return "localhost.localdomain" as a fallback
   default; and
 - various callsites of maildomain sub do not have to repeat the fallback
   default like your patch does.
Show 6 quoted lines
> @@ -962,9 +1014,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. ",
This part is a good addition, but it needs to be in the earlier patch, no?
Previous: Jari AaltoNext: Jari Aalto
Message 12 of 28 in “Do not strip empty lines / trailing spaces from a commit message template”
  1. Do not strip empty lines / trailing spaces from a commit message templateSebastian Schuberth, Mar 10, 2010
  2. Jeff KingMar 11, 2010
  3. Jeff KingMar 11, 2010
  4. Junio C HamanoMar 11, 2010
  5. Jeff KingMar 11, 2010
  6. Junio C HamanoMar 12, 2010
  7. Sebastian SchuberthMar 12, 2010
  8. Junio C HamanoMar 12, 2010
  9. git-send-email.perl - Fix 550 EHLO argument does not match calling hostJari Aalto, Mar 13, 2010
  10. Junio C HamanoMar 13, 2010
  11. git-send-email.perl - Fix 550 EHLO argument does not match calling hostJari Aalto, Mar 13, 2010
  12. Junio C HamanoMar 14, 2010
  13. Jari AaltoMar 14, 2010
  14. Junio C HamanoMar 14, 2010
  15. Jari AaltoMar 14, 2010
  16. Jari AaltoMar 14, 2010
  17. git-send-email.perl - Fix 550 EHLO argument does not match calling hostJari Aalto, Mar 14, 2010
  18. Junio C HamanoMar 14, 2010
  19. Jari AaltoMar 14, 2010
  20. Jari AaltoMar 14, 2010
  21. Jakub NarebskiMar 14, 2010
  22. Jari AaltoMar 14, 2010
  23. 1/3 git-send-email.perl: improve error message in send_message()Jari Aalto, Mar 14, 2010
  24. 2/3 git-send-email.perl: add option --smtp-debugJari Aalto, Mar 14, 2010
  25. 3/3 git-send-email.perl - Fix 550 EHLO argument does not match calling hostJari Aalto, Mar 14, 2010
  26. Jakub NarebskiMar 14, 2010
  27. Jari AaltoMar 14, 2010
  28. git-send-email.perl - Fix 550 EHLO argument does not match calling hostJari Aalto, Mar 14, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.