email-verifier icon indicating copy to clipboard operation
email-verifier copied to clipboard

fix: reachable should no when SMTP host not exists

Open everyx opened this issue 1 year ago • 3 comments

This PR sets ret.Reachable to reachableNo and returns ErrNoSuchHost when CheckMX returns the error ...no such host...

everyx avatar Nov 29 '24 08:11 everyx

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 avatar Dec 04 '24 17:12 emilianocalzada

@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

everyx avatar Dec 04 '24 23:12 everyx

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

emilianocalzada avatar Dec 05 '24 03:12 emilianocalzada

Hey! Any news on this one? I just noticed that I was getting unhandled "no such host" errors too 👌

solher avatar Nov 13 '25 14:11 solher

would be nice to get this fixed

emilianocalzada avatar Nov 26 '25 15:11 emilianocalzada

LGTM

lryong avatar Dec 04 '25 10:12 lryong