client.EmailValidation()
Email Validation
Validates an email address and reports whether it is deliverable.
Requires an API Key licensed for email validation. A query over 320 characters is rejected.
A validated address decrements your lookup balance. An address the API cannot check returns unknown and costs no lookup. An address whose domain does not resolve, or publishes no MX records, returns not_deliverable and also costs no lookup. Only those two domain failures populate suggestions. Every other response returns an empty list.
Endpoint
GET /emails
See the API reference for this endpoint.
Signature
func (c *Client) EmailValidation(ctx context.Context, query string, params *EmailValidationParams) (*EmailResponse, error)Arguments
| Name | Type | Required | Description |
|---|---|---|---|
ctx | context.Context | yes | Cancels the request and sets its deadline. |
query | string | yes | Specifies the email address to validate |
params | *EmailValidationParams | no | Optional query parameters, or nil. Fields under Query Parameters. |
Query Parameters
A required parameter is a method argument. Set the rest as fields of params, named in Studly case (post_town is PostTown); a field left at its zero value is not sent.
| Name | Type | Required | Description |
|---|---|---|---|
query | string | yes | Specifies the email address to validate |
tags | string | no | Tags |
Response
*idealpostcodes.EmailResponse. Fields the API may leave out or send as null are pointers. RawJSON() returns the body as received. See responses.
Errors
An HTTP error returns *idealpostcodes.APIError with the HTTP status, the API error code and the body; match it with errors.AsType. A transport failure returns the net/http error, wrapped. See error handling.
Example
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)
fmt.Println("Deliverable:", email.Deliverable)
return
}
fmt.Println("Deliverability unknown")
}