Skip to main content

Email validation

EmailValidation() checks whether an email address can receive mail, wherever its domain is hosted. It also flags disposable, free, role and catch-all addresses.

email.gogo
package main

import (
"context"
"fmt"
"log"

addresszen "go.addresszen.com/sdk"
)

func main() {
client := addresszen.NewClient("ak_test")
res, err := client.EmailValidation(context.Background(), "support@addresszen.com", nil)
if err != nil {
log.Fatal(err)
}
if email := res.Result.AsEmail(); email != nil {
fmt.Println(email.Result, "deliverable:", email.Deliverable)
return
}
fmt.Println("Could not check this address")
}

The address is the second argument. Your key needs email validation enabled.

Result​

Result is one of three values:

ResultMeaningType
deliverableThe mailbox accepts mailEmail, with Deliverable true
not_deliverableMail will bounce, or the domain cannot receive mailEmail, with Deliverable false
unknownThe API could not check the addressUnknownEmail, with every flag nil

An Email carries four more flags, each a bool:

  • Disposable: a throwaway domain, such as temp-mail.org
  • Free: a free provider, such as Gmail or Outlook
  • Role: a shared mailbox, such as admin@ or support@
  • Catchall: the domain accepts mail for any name, so a deliverable result proves less

res.Result.AsEmail() returns nil for an unknown result, and AsUnknownEmail() returns it instead.

Corrections​

Only when the domain does not resolve or publishes no MX records, Suggestions can hold corrected addresses. The API does not validate them, so check one before you use it. Every other result returns an empty list.

Cost​

One lookup for a checked address. An unknown result is free, and so is a domain that does not resolve or has no MX records. The API rejects an address over 320 characters with an *APIError.

See EmailValidation() for the parameters.