$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
public function emailValidation(array $params): EmailResponse
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
$params | array | yes | Query parameters. Keys under Query Parameters. |
Query Parameters
Pass these as keys of $params.
| Name | Type | Required | Description |
|---|---|---|---|
query | string | yes | Specifies the email address to validate |
tags | string|list<string> | no | Tags |
Response
IdealPostcodes\Responses\EmailResponse. Read fields as properties, such as $response->result, or as an array with the API's field names. toArray() returns the decoded body.
Errors
An HTTP error throws ApiException with the HTTP status, the API error code from getCode() and the decoded body. A transport failure throws TransporterException. See error handling.
Example
<?php
declare(strict_types=1);
use IdealPostcodes\IdealPostcodes;
use IdealPostcodes\Types\Email;
require 'vendor/autoload.php';
$client = IdealPostcodes::client('ak_test');
$response = $client->emailValidation(['query' => 'support@ideal-postcodes.co.uk']);
$result = $response->result;
if ($result instanceof Email) {
echo $result->result, PHP_EOL;
echo 'Deliverable: ', var_export($result->deliverable, true), PHP_EOL;
echo 'Disposable: ', var_export($result->disposable, true), PHP_EOL;
} else {
echo 'Deliverability unknown', PHP_EOL;
}