Golang package for email validation.
- Format (simple regexp, see: https://www.w3.org/TR/html5/forms.html#valid-e-mail-address and https://davidcel.is/posts/stop-validating-email-addresses-with-regex/)
- Valid domain
- Valid user: verify if the user and mailbox really exist
func main() {
err := checkmail.ValidateFormat("ç$€§/[email protected]")
if err != nil {
fmt.Println(err)
}
}
output: invalid format
func main() {
err := checkmail.ValidateHost("[email protected]")
if err != nil {
fmt.Println(err)
}
}
output: unresolvable host
func main() {
err := checkmail.ValidateHost("[email protected]")
if smtpErr, ok := err.(checkmail.SmtpError); ok && err != nil {
fmt.Printf("Code: %s, Msg: %s", smtpErr.Code(), smtpErr)
}
}
output: Code: 550, Msg: 550 5.1.1 The email account that you tried to reach does not exist.
Checkmail is licensed under the MIT License.