mailhog / MailHog

Web and API based SMTP testing
MIT License
14.15k stars 1.07k forks source link

`-hostname` is not used for HELO #257

Open svoop opened 5 years ago

svoop commented 5 years ago

This is from the MailHog -help:

-hostname string
 Hostname for EHLO/HELO response, e.g. mailhog.example (default "mailhog.example")

Start MailHog as follows:

mailhog -hostname development.myserver.com

Then release a mail, my recipient SMTP server logs:

NOQUEUE: reject: RCPT from xxx.xxx.net[xxx.xxx.xxx.xxx]: 504 5.5.2 <localhost>:
Helo command rejected: need fully-qualified hostname;
from=<nobody@development.myserver.com>
to=<me@myserver.com> 
proto=ESMTP
helo=<localhost>

Apparently, the -hostname is only used for MAIL FROM (which is good) and not for HELO/ELHO (which kills the release feature on many SMTP hosts).

ns3777k commented 5 years ago

well, that's because mailhog uses simple smtp.SendMail (https://github.com/mailhog/MailHog-Server/blob/master/api/v1.go#L335) function which is hard coded to use localhost (https://golang.org/src/net/smtp/smtp.go#L69).

the only option is to create a smtp client and call Hello method with desired host (https://golang.org/src/net/smtp/smtp.go#L91).