Skip to content

Latest commit

 

History

History
114 lines (86 loc) · 2.31 KB

README.md

File metadata and controls

114 lines (86 loc) · 2.31 KB

CI codecov Go Report Card Go Reference

email-validator

Go library to verify email addresses through Email verification API provided by 3rd party services - abstractapi.com and hunter.io.

Features

  • Completely native (no 3rd party module dependencies)
  • Client side rate limiting
  • Ability to change rate limits

How to use http clients

abstract.com client

import (
    "fmt"
    "log"
    "os"

    emailvalidator "github.com/r-goswami/email-validator"
)

func main() {
    apiKey :=  os.GetEnv("API_KEY")
    validator, err := emailvalidator.NewAbstractAPIClient(apiKey)
    if err != nil {
        log.Panic(err)
    }

    email := "[email protected]"
    resp, err := validator.Validate(email)
    if err != nil {
        fmt.Println(err)
        return
    }

    if resp.IsValid() {
        fmt.Printf("\n%s is a valid email\n", email)
    }
}

hunter.io client

import (
    "fmt"
    "log"
    "os"

    emailvalidator "github.com/r-goswami/email-validator"
)

func main() {
    apiKey :=  os.GetEnv("API_KEY")
    validator, err := emailvalidator.NewHunterAPIClient(apiKey)
    if err != nil {
        log.Panic(err)
    }

    email := "[email protected]"
    resp, err := validator.Validate(email)
    if err != nil {
        fmt.Println(err)
        return
    }

    if resp.IsValid() {
        fmt.Printf("\n%s is a valid email\n", email)
    }
}

How to check clients using commands

abstract.com client

Build

cd cmd/aapi_validate
go build

Run

cd cmd/aapi_validate
./aapi_validate validate -apiKey API_KEY -email EMAIL

hunter.io client

Build

cd cmd/hunter_validate
go build

Run

cd cmd/hunter_validate
./hunter_validate validate -apiKey API_KEY -email EMAIL