truemail-rb / truemail-go

🚀 Configurable Golang 📨 email validator/verifier. Verify email via Regex, DNS, SMTP and even more. Be sure that email address valid and exists.

Home Page:https://truemail-rb.org/truemail-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] There is an issue in the Validate function where it panics, root cause is in the runSession function

rahultyagidev opened this issue · comments

The bug is in the runSession function when creating smtp client we ignore the error, however calling either Send or Close in case there is an error causes panic

New bug checklist

Bug description

The bug is in the runSession function when creating smtp client we ignore the error on line 105, however calling either Send or Close in case there is an error causes panic:
Screenshot 2023-10-12 at 4 52 50 PM

Hi, @rahultyagidev! Thanks for your report. I'll take a look deeply.

Hi, is there any update on this case/bug reports?

Recently I also stumbling into the same issue where the module will resulting runtime error.

The runtime error only happen when initial connection to MX server is failed/instantly rejected.

I do some testing to actually handle the smtp.NewClient error in smtp_client.go instead of ignoring it, below are the changes:

before:

client, _ := smtp.NewClient(connection, smtpClient.targetServerAddress)

after:

client, err := smtp.NewClient(connection, smtpClient.targetServerAddress)
// Handle connection to MX failed
if err != nil {
	closeConnection()
	return false
}

IDK if that's the correct/best solution or not, but when I try to reproduce the error again using my test above the error is not appearing again.

@RichiMaulana The real cause of this error was the wrong SMTP service ready status 🥇