# Email validation

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

Email.cscsharp

```csharp
using IdealPostcodes;

using var client = new IdealPostcodesClient("ak_test");

var result = (await client.EmailValidationAsync(new EmailValidationParams("support@ideal-postcodes.co.uk"))).Result;

if (result is Email email)
{
    Console.WriteLine($"{email.Result} deliverable={email.Deliverable}");
}
else
{
    Console.WriteLine($"Could not check: {string.Join(", ", result.Suggestions)}");
}
```

The address is the one required parameter, so it is the `EmailValidationParams` constructor argument. Your key needs email validation enabled.

## Result

`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 `bool` flags:

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

`Result` and `Suggestions` are on `IEmailResponseResult`, so they read without a type check.

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

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