# git-send-email and "mailhost" misbehavior

2 messages from 2010-11-15 to 2010-11-16. Participants: Mike Frysinger, Junio C Hamano.
Thread: https://gitlist.dev/t/25754

## Mike Frysinger, 2010-11-15 20:24

Subject: git-send-email and "mailhost" misbehavior
Message-ID: <AANLkTinAjqb7cuCaiu=UvT9m5R=RM5E0hf4zPuKYVmHn@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTinAjqb7cuCaiu%3DUvT9m5R%3DRM5E0hf4zPuKYVmHn%40mail.gmail.com

```
i have sendemail in my ~/.gitconfig setup like so:
[sendemail]
    smtpserver = localhost:1111

and i have a ssh tunnel running there to forward my e-mail to another
machine's localhost:25

however, when i attempt to send e-mail from some systems, the `git
send-email` process pauses for like 2 minutes without doing anything.
after hassling my e-mail admin about greylisting (which is disabled
for localhost), i looked at git-send-email a bit closer.

running it through a heavy strace shows the source of the pause:
connect(6, {sa_family=AF_INET, sin_port=htons(25),
sin_addr=inet_addr("208.68.139.38")}, 16)
then there's a timeout after 120 seconds trying to connect to this guy

so wtf is "208.68.139.38" !?  well, my shitty ISP (comcast) is doing
DNS hijacking for unresolved DNS names.  so git-send-email tried to
look up some host and it got back "208.68.139.38".  while comcast is
wrong here, why is git-send-email looking up anything at all
considering my sendemail.smtpserver is configured to localhost ?

it seems that buried in the bowels of git-send-email and totally
undocumented is this nugget:
/usr/libexec/git-core/git-send-email:
...
sub maildomain_mta {
    my $maildomain;

    if (eval { require Net::SMTP; 1 }) {
        for my $host (qw(mailhost localhost)) {
            my $smtp = Net::SMTP->new($host);
...

so git-send-email is so kind as to attempt port 25 connections to
"mailhost:25" and "localhost:25" while attempting to locate its FQDN
!?  this doesnt sound right at all.  DNS lookups do not require actual
TCP/IP connection attempts.

stubbing out "mailhost" to 127.0.0.1 in /etc/hosts fixes my troubles.
-mike

```

## Junio C Hamano, 2010-11-16 19:06

Subject: Re: git-send-email and "mailhost" misbehavior
Message-ID: <7vy68tgkb7.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy68tgkb7.fsf%40alter.siamese.dyndns.org
In-Reply-To: <AANLkTinAjqb7cuCaiu=UvT9m5R=RM5E0hf4zPuKYVmHn@mail.gmail.com>

```
Mike Frysinger <vapier@gentoo.org> writes:

> i have sendemail in my ~/.gitconfig setup like so:
> [sendemail]
>     smtpserver = localhost:1111
>
> and i have a ssh tunnel running there to forward my e-mail to another
> machine's localhost:25
>
> however, when i attempt to send e-mail from some systems, the `git
> send-email` process pauses for like 2 minutes without doing anything.
> after hassling my e-mail admin about greylisting (which is disabled
> for localhost), i looked at git-send-email a bit closer.
>
> running it through a heavy strace shows the source of the pause:
> connect(6, {sa_family=AF_INET, sin_port=htons(25),
> sin_addr=inet_addr("208.68.139.38")}, 16)
> then there's a timeout after 120 seconds trying to connect to this guy
>
> so wtf is "208.68.139.38" !?  well, my shitty ISP (comcast) is doing
> DNS hijacking for unresolved DNS names.  so git-send-email tried to
> look up some host and it got back "208.68.139.38".  while comcast is
> wrong here, why is git-send-email looking up anything at all
> considering my sendemail.smtpserver is configured to localhost ?
>
> it seems that buried in the bowels of git-send-email and totally
> undocumented is this nugget:
> /usr/libexec/git-core/git-send-email:
> ...
> sub maildomain_mta {
>     my $maildomain;
>
>     if (eval { require Net::SMTP; 1 }) {
>         for my $host (qw(mailhost localhost)) {
>             my $smtp = Net::SMTP->new($host);
> ...
>
> so git-send-email is so kind as to attempt port 25 connections to
> "mailhost:25" and "localhost:25" while attempting to locate its FQDN
> !?  this doesnt sound right at all.  DNS lookups do not require actual
> TCP/IP connection attempts.
>
> stubbing out "mailhost" to 127.0.0.1 in /etc/hosts fixes my troubles.
> -mike

Redirecting to Jari Aalto for 134550f (git-send-email.perl - try to give
real name of the calling host to HELO/EHLO, 2010-03-14)

```
