Skip to main content

client.email_validation

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​

def email_validation(query:, tags: nil)

Arguments​

NameTypeRequiredDescription
keywordskeyword argumentsyesOne per query parameter, named as the API names them. A keyword left out or nil is not sent.

Query Parameters​

Pass these as keyword arguments.

NameTypeRequiredDescription
queryStringyesSpecifies the email address to validate
tagsString, Array<String>noTags

Response​

IdealPostcodes::Responses::EmailResponse. Read fields with readers named as the API names them, such as response.result, or with response["result"]. to_h returns the decoded body.

Errors​

An HTTP error raises IdealPostcodes::ApiError with the HTTP status, the API error code and the decoded body. A transport failure raises IdealPostcodes::TransportError. See error handling.

Example​

email-validation.rbruby
require "ideal_postcodes"

client = IdealPostcodes::Client.new(api_key: "ak_test")

response = client.email_validation(query: "support@ideal-postcodes.co.uk")

result = response.result

if result.is_a?(IdealPostcodes::Types::Email)
puts result.result
puts "Deliverable: #{result.deliverable}"
puts "Disposable: #{result.disposable}"
else
puts "Deliverability unknown"
end