Documentation
¶
Overview ¶
Package truelist provides a Go client for the Truelist.io email validation API.
Create a client with your API key and use it to validate emails:
client := truelist.NewClient("your-api-key")
result, err := client.Validate(ctx, "user@example.com")
if err != nil {
log.Fatal(err)
}
fmt.Println(result.IsValid())
Index ¶
Constants ¶
const ( StateOK = "ok" StateEmailInvalid = "email_invalid" StateAcceptAll = "accept_all" )
State constants for email validation results.
const ( SubStateEmailOK = "email_ok" SubStateIsDisposable = "is_disposable" SubStateIsRole = "is_role" SubStateUnknownError = "unknown_error" SubStateFailedSMTP = "failed_smtp_check" )
SubState constants for email validation results.
Variables ¶
var ( // ErrAuthentication is returned when the API key is invalid or missing. ErrAuthentication = errors.New("authentication failed") // ErrRateLimit is returned when the API rate limit is exceeded. ErrRateLimit = errors.New("rate limit exceeded") // ErrAPI is returned for general API errors. ErrAPI = errors.New("API error") )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
Email string `json:"email"`
Name string `json:"name"`
UUID string `json:"uuid"`
TimeZone string `json:"time_zone"`
IsAdminRole bool `json:"is_admin_role"`
Account AccountInfo `json:"account"`
}
Account represents the response from the account info endpoint.
type AccountInfo ¶
AccountInfo represents the nested account details.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Truelist API client.
type Option ¶
type Option func(*Client)
Option configures the Client.
func WithBaseURL ¶
WithBaseURL sets a custom base URL for the API.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client.
func WithMaxRetries ¶
WithMaxRetries sets the maximum number of retries for transient errors (429, 5xx). Set to 0 to disable retries. Default is 3.
func WithTimeout ¶
WithTimeout sets the HTTP client timeout.
type Result ¶
type Result struct {
Email string `json:"address"`
Domain string `json:"domain"`
Canonical string `json:"canonical"`
MxRecord *string `json:"mx_record"`
FirstName *string `json:"first_name"`
LastName *string `json:"last_name"`
State string `json:"email_state"`
SubState string `json:"email_sub_state"`
VerifiedAt string `json:"verified_at"`
Suggestion *string `json:"did_you_mean"`
}
Result represents the response from an email validation request.
func (*Result) IsAcceptAll ¶
IsAcceptAll returns true if the email state is "accept_all".
func (*Result) IsDisposable ¶
IsDisposable returns true if the email sub-state is "is_disposable".