# 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.phpphp

```php
use IdealPostcodes\IdealPostcodes;
use IdealPostcodes\Types\Email;

$client = IdealPostcodes::client('ak_test');
$email = $client->emailValidation(['query' => 'support@ideal-postcodes.co.uk'])->result;

if ($email instanceof Email) {
    echo $email->result, ' deliverable=', var_export($email->deliverable, true), PHP_EOL;
} else {
    echo 'Could not check: ', implode(', ', $email->suggestions), PHP_EOL;
}
```

Your key needs email validation enabled.

## What does the result mean?

`result` is one of three values:

| `result`          | Meaning                                             | Class                                  |
| ----------------- | --------------------------------------------------- | -------------------------------------- |
| `deliverable`     | The mailbox accepts mail                            | `Email`, with `deliverable` `true`     |
| `not_deliverable` | Mail will bounce, or the domain cannot receive mail | `Email`, with `deliverable` `false`    |
| `unknown`         | The API could not check the address                 | `UnknownEmail`, with every flag `null` |

An `Email` carries four more flags, each `true` or `false`:

* `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

An `UnknownEmail` has the same properties typed `null`, so an `instanceof Email` check narrows them to `bool`.

## Does it suggest corrections?

Sometimes. 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.

## What does it 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 `ApiException`.

See [`validate`](/docs/sdks/php/endpoints/email-validation.md) for the parameters and the [email validation guide](/docs/guides/email-validation.md) for how the checks work.
