An easy-to-use Go library using Kickbox.io for email address validation
Go
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE
README.md
kickbox.go
kickbox_result.go
kickbox_result_test.go
kickbox_test.go
result.go

README.md

Build Status GoDoc

kickbox

An easy-to-use Go library using Kickbox.io for email address validation

Example

Install a tagged version with: go get github.com/domodwyer/kickbox

// Create a new client with your API key
kickbox := kickbox.NewClient("KICKBOX_TEST")

// Verify an email address
result, err := kickbox.Verify("dom@itsallbroken.com")
if err != nil {
    panic("something went wrong :( ")
}

// Interact with the response!
if(result.IsDeliverable()) {
    log.Print("Send some stuff to ", result.Email)
}

Usage

The Verify() method returns an instance of Kickbox.Result and is mapped onto the Kickbox API response:

type Result struct {
    Success    bool    `json:"success"`
    Result     string  `json:"result"`
    Reason     string  `json:"reason"`
    Disposable bool    `json:"disposable"`
    Role       bool    `json:"role"`
    Free       bool    `json:"free"`
    AcceptAll  bool    `json:"accept_all"`
    Suggested  string  `json:"did_you_mean"`
    Sendex     float32 `json:"sendex"`
    Email      string  `json:"email"`
    User       string  `json:"user"`
    Domain     string  `json:"domain"`
    Message    string  `json:"message"`
}

For convenience Kickbox.Result also recieves several helper methods:

func (r Result) IsDeliverable() bool {
    return (r.Result == "deliverable")
}

func (r Result) IsUndeliverable() bool {
    return (r.Result == "undeliverable")
}

func (r Result) IsRisky() bool {
    return (r.Result == "risky")
}

func (r Result) IsUnknown() bool {
    return (r.Result == "unknown")
}