Email validation

EmailValidation() checks whether an email address can receive mail before you store it. It also flags disposable, free, role and catch-all addresses.

email.gogo
package main

import (
	"context"
	"fmt"
	"log"

	idealpostcodes "go.ideal-postcodes.co.uk/sdk"
)

func main() {
	client := idealpostcodes.NewClient("ak_test")
	res, err := client.EmailValidation(context.Background(), "support@ideal-postcodes.co.uk", 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.com or outlook.com
  • Role: a role mailbox, such as admin@ or support@
  • Catchall: the domain accepts mail for any mailbox, so a deliverable result proves less

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

Corrections​

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

Cost​

One lookup for a checked address. An unknown result costs nothing, and neither does 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 and the email validation guide for how the checks work.