:white_check_mark: A Go library for email verification without sending any emails.

email-verifier

✉️ A Go library for email verification without sending any emails.

Build Status Godoc Coverage Status Go Report Card license

Features

  • Email Address Validation: validates if a string contains a valid email.
  • Email Verification Lookup via SMTP: performs an email verification on the passed email
  • MX Validation: checks the DNS MX records for the given domain name
  • Misc Validation: including Free email provider check, Role account validation, Disposable emails address (DEA) validation
  • Email Reachability: checks how confident in sending an email to the address

Install

Use go get to install this package.

go get -u github.com/AfterShip/email-verifier

Usage

Basic usage

Use Verify method to verify an email address with different dimensions

package main

import (
    "fmt"

    "github.com/AfterShip/email-verifier"
)

var (
    verifier = emailverifier.NewVerifier()
)

func main() {

    email := "[email protected]"
    ret, err := verifier.Verify(email)
    if err != nil {
        fmt.Println("check email failed: ", err)
        return
    }

    fmt.Println("email validation result", ret)
}

Email verification Lookup

Use CheckSMTP to performs an email verification lookup via SMTP.

var (
    verifier = emailverifier.
        NewVerifier().
        EnableSMTPCheck()
)

func main() {

    domain := "domain.org"
    ret, err := verifier.CheckSMTP(domain)
    if err != nil {
        fmt.Println("check smtp failed: ", err)
        return
    }

    fmt.Println("smtp validation result: ", ret)

}

Note: because most of the ISPs block outgoing SMTP requests through port 25 to prevent email spamming, the module will not perform SMTP checking by default. You can initialize the verifier with EnableSMTPCheck() to enable such capability if port 25 is usable.

Misc Validation

To check if an email domain is disposable via IsDisposable

var (
    verifier = emailverifier.
        NewVerifier().
        EnableAutoUpdateDisposable()
)

func main() {
    domain := "domain.org"
    ret := verifier.IsDisposable(domain)
    fmt.Println("misc validation result: ", ret)
}

Note: It is possible to automatically update the disposable domains daily by initializing verifier with EnableAutoUpdateDisposable()

For more detailed documentation, please check on godoc.org 👉 email-verifier

Similar Libraries Comparison

email-verifier trumail check-if-email-exists freemail
Features 〰️ 〰️ 〰️ 〰️
Disposable email address validation , but not available in free lib
Disposable address autoupdate 🤔
Free email provider check , but not available in free lib
Role account validation
Syntax validation
Email reachability
DNS records validation
Email deliverability
Mailbox disabled
Full inbox
Host exists
Catch-all
Gravatar , but not available in free lib
Typo check 🔜 , but not available in free lib
Honeyport dection 🔜
Bounce email check 🔜
Tech 〰️ 〰️ 〰️ 〰️
Provide API 🔜
Free API 🔜
Language Go Go Rust JavaScript
Active maintain
High Performance

FAQ

The library hangs/takes a long time after 30 seconds when performing email verification lookup via SMTP

Most ISPs block outgoing SMTP requests through port 25 to prevent email spamming. email-verifier needs to have this port open to make a connection to the email's SMTP server. With the port being blocked, it is not possible to perform such checking, and it will instead hang until timeout error. Unfortunately, there is no easy workaround for this issue.

For more information, you may also visit this StackOverflow thread.

The output shows "connection refused" in the smtp.error field.

This error can also be due to SMTP ports being blocked by the ISP, see the above answer.

What does reachable: "unknown" means

This means that the server does not allow real-time verification of an email right now, or the email provider is a catch-all email server.

Credits

Contributing

For details on contributing to this repository, see the contributing guide.

License

This package is licensed under MIT license. See LICENSE for details.

Comments
  • Failed when check STMP use SOCKS5 proxy

    Failed when check STMP use SOCKS5 proxy

    Hi there, I tried to use the new feature "Support Use the specified SOCKS5 proxy host to perform email verification" of @lryong When I check smtp, the response is: "check smtp failed: EOF : EOF" I debugged, the code throw exception in function NewClient() (located in file stmp.go), in line 64 when call text.ReadResponse(220) Please help me for that.

  • how can i do smtp check with general validation?

    how can i do smtp check with general validation?

    I need result like this format { "email": "[email protected]", "disposable": false, "reachable": "unknown", "role_account": false, "free": false, "syntax": { "username": "tuyensinh", "domain": "ued.udn.vn", "valid": true }, "has_mx_records": true, "smtp": { "host_exists": true, "full_inbox": false, "catch_all": true, "deliverable": false, "disabled": false }, "gravatar": null, "suggestion": "" }

  •  Having issue with verifying emails of custom domain

    Having issue with verifying emails of custom domain

    [email protected] [email protected]

    I tried to test 2 email address with your library but it is giving same answer although the second one isn't existed. Can you tell me what wrong I did ?

    This is result I got: smtp validation result: &{true false true false false}

  • Gravatar is always valid.

    Gravatar is always valid.

    Even if the gravatar image does not exist the verifier return true and a link.

    The URL should have d parameter to get 404 code from gravatar. For example, https://www.gravatar.com/avatar/00000000000000000000000000000001?d=404 instead of https://www.gravatar.com/avatar/00000000000000000000000000000001

  • Address Verify(

    Address Verify("abce") returns no error?

    For invalid syntax email address, the Verify() func returns err is nil. For example

    emailverifier.NewVerifier()
    ret, verifyErr := verifier.Verify("abce")
    // verifyErr is nil 
    

    In code, I think at least here will return a error, rather than nil?

    	if !syntax.Valid {
    		return &ret, nil
    	}
    
    
  • data file load issue if compile and runtime are in different computer

    data file load issue if compile and runtime are in different computer

    In your documentation, there is no mention that this library has a dependency on the data folder. Until I want to compile my code on the CI server and deploy it to the production server. I found this library loading data file base on runtime.Caller(). However, runtime.Caller returns the compiled GOPATH instead of the real "runtime" path. This makes this cross-machine deployment impossible. https://stackoverflow.com/questions/51368837/golang-runtime-package-sets-filepaths-from-the-system-on-which-it-was-built

    I am not expert on golang, no sure how your guys to cope with this? Any reason use a compile time base path?

    Here is how your code get data basePath: _, b, _, _ = runtime.Caller(0) basePath = filepath.Dir(b)

    One more question, is this project still alive? I don't see any activities after initial commit. Thank you.

  • Unable to run code

    Unable to run code

    I am unable to run this code . can you please let us know the process. how to run this code. its showing error main.go:6:2: found packages emailverifier (address.go) and main (main.go) in /Users/user/workplace/email-verifier

    Screenshot 2021-05-12 at 1 08 13 AM

  • MOD: return value instead of reference

    MOD: return value instead of reference

    In address.go, ParseAddress return *Syntax, I think return value instead of reference is better for reducing GC pressure and improve memory locality.

    Here is the benchmark for return value vs return reference

    goos: linux
    goarch: amd64
    pkg: github.com/AfterShip/email-verifier
    cpu: AMD Ryzen 7 PRO 4750G with Radeon Graphics
    BenchmarkCheckAddressSyntax-16        190801       6278 ns/op      385 B/op        8 allocs/op
    BenchmarkCheckAddressSyntax1-16       207202       5660 ns/op        0 B/op        0 allocs/op
    PASS
    

    Returning value is faster due to no memory allocation needed.

    I ran go build -gcflags='-m' it shows a lot of ... escapes to heap

    Although it's also a matter of style, what do you think?

  • Bump github.com/stretchr/testify from 1.7.1 to 1.7.5

    Bump github.com/stretchr/testify from 1.7.1 to 1.7.5

    Bumps github.com/stretchr/testify from 1.7.1 to 1.7.5.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump github.com/stretchr/testify from 1.7.1 to 1.7.4

    Bump github.com/stretchr/testify from 1.7.1 to 1.7.4

    Bumps github.com/stretchr/testify from 1.7.1 to 1.7.4.

    Commits
    • 48391ba Fix panic in AssertExpectations for mocks without expectations (#1207)
    • 840cb80 arrays value types in a zero-initialized state are considered empty (#1126)
    • 07dc7ee Bump actions/setup-go from 3.1.0 to 3.2.0 (#1191)
    • c33fc8d Bump actions/checkout from 2 to 3 (#1163)
    • 3c33e07 Added Go 1.18.1 as a build/supported version (#1182)
    • e2b56b3 Bump github.com/stretchr/objx from 0.1.0 to 0.4.0
    • 41453c0 Update gopkg.in/yaml.v3
    • 285adcc Update go versions in build matrix
    • 6e7fab4 Bump actions/setup-go from 2 to 3.1.0
    • 106ec21 use RWMutex
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump github.com/stretchr/testify from 1.7.1 to 1.7.2

    Bump github.com/stretchr/testify from 1.7.1 to 1.7.2

    Bumps github.com/stretchr/testify from 1.7.1 to 1.7.2.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Yahoo seems to incorrectly return catch_all=true and deliverable=false

    Yahoo seems to incorrectly return catch_all=true and deliverable=false

    Hi, The results for yahoo seem to be incorrect.

    I get this result for valid yahoo addresses.

    {"host_exists":true,"full_inbox":false,"catch_all":true,"deliverable":false,"disabled":false}
    

    If I try and email a random yahoo email like the ones used for catch_all detection, I receive a bounce back.

    It seems like SMTP RCPT verification is not enough for yahoo and possibly other providers.

    Perhaps this project could maintain a list of providers that don't work and return an 'unknown' response.

    Ps, thanks for the nice project.

✉️ A Go library for email verification without sending any emails.

email-verifier ✉️ A Go library for email verification without sending any emails. Features Email Address Validation: validates if a string contains a

Jun 24, 2021
Mail_sender - This library is for sending emails from your mail

Mail Sender This library is for sending emails from your mail Installation mail_

Dec 30, 2021
A simple microservice designed in Go using Echo Microframework for sending emails and/or calendar invitations to users.

Calenvite A simple microservice designed in GO using Echo Microframework for sending emails and/or calendar invitations to users. Features Send emails

Oct 29, 2022
In this project I just created email-verification Code.

mail-verification In this project I just created email-verification Code. Setup Before run the program. Type go mod tidy on terminal. After that chang

Nov 4, 2021
Golang library for sending email using gmail credentials

library for sending email using gmail credentials

Jan 22, 2022
Pretty wrapper for sending email using go net/smtp

Emailer A pretty wrapper around go net/smtp send multiple email using single client func main() { var client *emailer.Client var clientX sync.Mute

Mar 23, 2022
VMail - check the markup (HTML, CSS) of HTML email template compatibility with email clients
VMail - check the markup (HTML, CSS) of HTML email template compatibility with email clients

VMail - check the markup (HTML, CSS) of HTML email template compatibility with email clients Email clients use different rendering standards. This is

Dec 17, 2022
Email-searcher - Given a domain name and real name, attempt to find an existing email for that user.

email-searcher Given a domain name and real name, attempt to find an existing email for that user. Using Run it with both the domain and name flags, l

Jan 2, 2022
The best way to send emails in Go.

Gomail Introduction Gomail is a simple and efficient package to send emails. It is well tested and documented. Gomail can only send emails using an SM

Dec 29, 2022
An easy way to send emails with attachments in Go

PROJECT DISCONTINUED This repository only exists for archival purposes. email An easy way to send emails with attachments in Go Install go get github.

Dec 12, 2022
Sort the emails contained in a .csv file into a text file

Go convert csv to txt This snippet of code allows you to sort the emails contained in a .csv file into a text file.

Nov 23, 2021
Hxgomail - Gomail - a simple and efficient package to send emails

Gomail Introduction Gomail is a simple and efficient package to send emails. It

Jan 4, 2022
Go library for sending mail with the Mailgun API.

Mailgun with Go Go library for interacting with the Mailgun API. Usage package main import ( "context" "fmt" "log" "time" "githu

Dec 25, 2022
Robust and flexible email library for Go

email Robust and flexible email library for Go Email for humans The email package is designed to be simple to use, but flexible enough so as not to be

Dec 30, 2022
Mcopa - A library allows for parsing an email message into a more convenient form than the net/mail provides

Mail content parsing This library allows for parsing an email message into a mor

Jan 1, 2022
Golang package that generates clean, responsive HTML e-mails for sending transactional mail
Golang package that generates clean, responsive HTML e-mails for sending transactional mail

Hermes Hermes is the Go port of the great mailgen engine for Node.js. Check their work, it's awesome! It's a package that generates clean, responsive

Dec 28, 2022
📧 Example of sending mail via SendGrid in Golang.

?? go-sendgrid-example Example of sending mail via SendGrid in Golang. Get it started $ make setup # Edit environment variables $ vim ./env/local.env

Jan 11, 2022
Golang package for send email. Support keep alive connection, TLS and SSL. Easy for bulk SMTP.

Go Simple Mail The best way to send emails in Go with SMTP Keep Alive and Timeout for Connect and Send. IMPORTANT Examples in this README are for v2.2

Jan 8, 2023
An email MIME artist for golang

Marcel is a tool to generate IETF compliant emails in raw MIME format. I mainly use this for generating emails with attachments and sending them via amazon SES. If that's what you're doing too, you may want notifications

Nov 7, 2022