emailable

package module
v0.0.0-...-4ab5f1c Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: MIT Imports: 9 Imported by: 0

README

emailable-go

Unofficial implementation of the emailable api for Go

This is mainly used for me internly, and each feature that I may need will be added in the futur

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchRequest

type BatchRequest struct {
	Emails   []string      `json:"emails"`  // A comma separated list of emails.
	Url      string        `json:"url"`     // A URL that will receive the batch results via HTTP POST.
	Retries  bool          `json:"retries"` // Defaults to true. Retries increase accuracy by automatically retrying verification when our system receives certain responses from mail servers.
	Simulate SimulateValue `json:"string"`  // Used to simulate certain responses from the API while using a test key.
	ApiKey   string        `json:"api_key"`
}

type BatchResponse

type BatchResponse struct {
	Message string `json:"message"` // A message about your batch.
	Id      string `json:"id"`      // The unique ID of the batch.
}

type BatchStatusRequest

type BatchStatusRequest struct {
	Id       string `json:"id"`
	ApiKey   string `json:"api_key"`
	Partial  string `json:"partial"`
	Simulate string `json:"simulate"`
}

type BatchStatusResponse

type BatchStatusResponse struct {
	Message     string           `json:"message"`
	Processed   int64            `json:"processed"`
	Total       int64            `json:"total"`
	Emails      []VerifyResponse `json:"emails"`
	Id          string           `json:"id"`
	ReasonCount ReasonCount      `json:"reason_counts"`
	TotalCounts TotalCounts      `json:"total_counts"`
}

type EmailState

type EmailState string
const (
	ValidEmail   EmailState = "valid"
	InvalidEmail EmailState = "invalid"
	RiskyEmail   EmailState = "risky"
	BouncedEmail EmailState = "bounced"
	UnknownEmail EmailState = "unknown"
)

type Emailable

type Emailable struct {
	// contains filtered or unexported fields
}

func NewEmailable

func NewEmailable(apiKey string) Emailable

func (*Emailable) BatchFromFile

func (emailable *Emailable) BatchFromFile(file io.Reader) ([]BatchResponse, error)

func (*Emailable) BatchStatus

func (emailable *Emailable) BatchStatus(req *BatchStatusRequest) (*BatchStatusResponse, error)

func (*Emailable) BatchVerify

func (emailable *Emailable) BatchVerify(req BatchRequest) (*BatchResponse, error)

func (*Emailable) NewBatchReq

func (emailable *Emailable) NewBatchReq(emails []string) BatchRequest

func (*Emailable) NewBatchVerificationReq

func (emailable *Emailable) NewBatchVerificationReq(id string) BatchStatusRequest

func (*Emailable) NewVerifyReq

func (emailable *Emailable) NewVerifyReq(email string) VerifyRequest

func (*Emailable) Verify

func (emailable *Emailable) Verify(req VerifyRequest) (*VerifyResponse, error)

type ReasonCount

type ReasonCount struct {
	AcceptedEmail     int64 `json:"accepted_email"`
	InvalidDomain     int64 `json:"invalid_domain"`
	InvalidEmail      int64 `json:"invalid_email"`
	InvalidSmtp       int64 `json:"invalid_smtp"`
	LowDeliverability int64 `json:"low_deliverability"`
	LowQuality        int64 `json:"low_quality"`
	NoConnect         int64 `json:"no_connect"`
	RejectedEmail     int64 `json:"rejected_email"`
	Timeout           int64 `json:"timeout"`
	UnavailableSmtp   int64 `json:"unavailable_smtp"`
	UnexpectedError   int64 `json:"unexpected_error"`
}

type SimulateValue

type SimulateValue string
const (
	GenericError             SimulateValue = "generic_error"
	InsufficientCreditsError SimulateValue = "insufficient_credits_error"
	PaymentError             SimulateValue = "payment_error"
	CardError                SimulateValue = "card_error"
)

type TotalCounts

type TotalCounts struct {
	Deliverable   int64 `json:"deliverable"`
	Processed     int64 `json:"processed"`
	Risky         int64 `json:"risky"`
	Total         int64 `json:"total"`
	Undeliverable int64 `json:"undeliverable"`
	Unknown       int64 `json:"unknown"`
}

type VerifyRequest

type VerifyRequest struct {
	Email     string `json:"email"`      // The email you want verified.
	Smtp      bool   `json:"smtp"`       // "true" or "false". The SMTP step takes up a majority of the API's response time. If you would like to speed up your response times, you can disable this step. Default: true
	AcceptAll bool   `json:"accept_all"` // "true" or "false". Whether or not an accept-all check is performed. Heavily impacts API's response time. Default: false
	Timeout   uint8  `json:"timeout"`    // Optional timeout to wait for response (in seconds). Min: 5, Max: 30. Default: 5
	ApiKey    string `json:"api_key"`
}

type VerifyResponse

type VerifyResponse struct {
	AcceptAll    bool       `json:"accept_all"`    // Whether the mail server used to verify indicates that all addresses are deliverable regardless of whether or not the email is valid.
	DidYouMean   string     `json:"did_you_mean"`  // A suggested correction for a common misspelling.
	Disposable   bool       `json:"disposable"`    // Whether this email is hosted on a disposable or temporary email service.
	Domain       string     `json:"domain"`        // The domain of the email.
	Duration     float64    `json:"duration"`      // The length of time (in seconds) spent verifying this email.
	Email        string     `json:"email"`         // The email that was verified.
	FirstName    string     `json:"first_name"`    // The possible first name of the user.
	Free         bool       `json:"free"`          // Whether the email is hosted by a free email provider.
	FullName     string     `json:"full_name"`     // The possible full name of the user.
	Gender       string     `json:"gender"`        // The possible gender of the user.
	LastName     string     `json:"last_name"`     // The possible last name of the user.
	MxRecord     string     `json:"mx_record"`     // The address of the mail server used to verify the email.
	Reason       string     `json:"reason"`        // The reason for the associated state.
	Role         bool       `json:"role"`          // Whether the email is considered a role address.
	Score        int32      `json:"score"`         // The score of the verified email.
	SmtpProvider string     `json:"smtp_provider"` // The SMTP provider of the verified email's domain.
	State        EmailState `json:"state"`         // The state of the verified email
	Tag          string     `json:"tag"`           // The tag part of the verified email.
	User         string     `json:"user"`          // The user part of the verified email.
}

Jump to

Keyboard shortcuts

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