neverbounce

package module
v0.0.0-...-197a0d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2017 License: MIT Imports: 8 Imported by: 0

README

neverbounce

This is a client for the Email validation service Neverbounce(https://neverbounce.com/)

The implementation of this library was based on the docs: https://neverbounce.com/help/api/verifying-an-email/

Here is an example.

Usage:

   
neverbounce.Init(&neverbounce.NeverBounceCli{        
    ApiUsername: "NEVERBOUNCE_USERNAME",  
    ApiPassword: "NEVERBOUNCE_PASSWORD",  
})                                                   
neverbounce.VerifyEmail("someemail@example.com")

Due to the fact that this service might be used on the web in order to validate forms. This minimalist client allows a user to specify its test mode

    
neverbounce.Init(&neverbounce.NeverBounceCli{        
    ApiUsername: "NEVERBOUNCE_USERNAME",  
    ApiPassword: "NEVERBOUNCE_PASSWORD",
    TestMode: true,
})

neverbounce.VerifyEmail("anemail@valid.com")
neverbounce.VerifyEmail("anemail@invalid.com")
neverbounce.VerifyEmail("anemail@catchall.com")
neverbounce.VerifyEmail("anemail@disposable.com")
neverbounce.VerifyEmail("anemail@unknown.com")

When doing so this module will fake the never bounce service and the client will than make requests to the fake server.

The emails will than be validated follwing the creteria:

  • Emails ending in @valid.com will be considered valid
  • Enails ending in @invalid.com will be considered invalid
  • Emails ending in @disposable.com will result on a disposable result code.
  • Emails ending in @catchall.com will result on a catch all result code.
  • Email ending in @unknow.com will result on an unknown status code.

Please refer the services API documentation for further information.

https://neverbounce.com/help/api/verifying-an-email/

Documentation

Index

Constants

View Source
const (
	EMAIL_VALID      = 0
	EMAIL_INVALID    = 1
	EMAIL_DISPOSABLE = 2
	EMAIL_CATCHALL   = 3
	EMAIL_UNKNOWN    = 4
)
View Source
const DEFAULT_API_URL string = "https://api.neverbounce.com/v3"

Variables

This section is empty.

Functions

func GetAccessToken

func GetAccessToken() string

func GetFakeService

func GetFakeService() *httptest.Server

func Init

func Init(neverbounce *NeverBounceCli)

Types

type AccessTokenResponse

type AccessTokenResponse struct {
	AccessToken string `json:"access_token"`
	Expires     int    `json:"expires"`
}

type NeverBounceCli

type NeverBounceCli struct {
	ApiUrl      string
	ApiUsername string
	ApiPassword string
	AccessToken string

	TestMode bool
}
var NeverBounce *NeverBounceCli

func (*NeverBounceCli) GetAccessToken

func (n *NeverBounceCli) GetAccessToken() string

This function will get the client access token but also store it in the struct to be used in subsequent calls

func (*NeverBounceCli) SetApiUrl

func (n *NeverBounceCli) SetApiUrl(url string)

Sets the API url on the client

func (*NeverBounceCli) VerifyEmail

func (n *NeverBounceCli) VerifyEmail(email string) VerifyEmailResponse

Takes an email and verifies it

type VerifyEmailResponse

type VerifyEmailResponse struct {
	Success       bool   `json:"success"`
	Result        int    `json:"result"`
	ResultDetails int    `json:"result_details"`
	Msg           string `json:"msg"`
}

func VerifyEmail

func VerifyEmail(email string) VerifyEmailResponse

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL