fix: reachable should no when SMTP host not exists
This PR sets ret.Reachable to reachableNo and returns ErrNoSuchHost when CheckMX returns the error ...no such host...
Hey @everyx! Thanks for the PR! 😊 You helped me to notice something interesting in my logs - I was getting quite a few errors during SMTP checks like this:
"Mail server does not exist : lookup X on 127.0.0.11:53: no such host"
I implemented your suggested fix specifically for the CheckSMTP method with a small modification:
smtpResult, err := verifier.CheckSMTP(ret.Syntax.Domain, ret.Syntax.Username)
<-GlobalSemaphore
// Handle non-existent SMTP host
if err != nil {
errStr := err.Error()
if insContains(errStr, "no such host") {
ret.Reachable = reachableNo
err = nil // <- This is the modification I made
}
}
When CheckSMTP encounters a "no such host" error, it actually tells us something specific: the SMTP server for this domain doesn't exist, it means it is an reachableNo address. This is different from other SMTP errors like authentication issues or connection problems.
So this fix will also need to apply to CheckSMTP and not only to Verify methods
@emilianocalzada I'm not quite clear on what you mean, CheckSMTP is called after CheckMX, why continue to judge in CheckSMTP, CheckSMTP is only used to return the smtp field, and the no such host error has already been handled in parseBasicErr
Just to clarify, when we call the Verify() method with SMTP checks enabled, it will also call the CheckSMTP function, which can encounter the same "no such host" error since it is making the same MX servers check. Since CheckSMTP can be used independently, I think we should apply the same fix there as well
Hey! Any news on this one? I just noticed that I was getting unhandled "no such host" errors too 👌
would be nice to get this fixed
LGTM