> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailglyph.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Email Validation

> Validate email addresses, run bulk validation jobs, and inspect credits with the MailGlyph PHP SDK.

Use a **secret key** client for Email Validation.

```php theme={null}
<?php

use MailGlyph\MailGlyph;

$client = new MailGlyph($_ENV['MAILGLYPH_SECRET_KEY']);
```

## Validate one address

```php theme={null}
<?php

$result = $client->verification->validate('user@example.com');

var_dump($result->valid);
var_dump($result->validationMethod);
var_dump($result->smtpStatus);
var_dump($result->creditsConsumed);
var_dump($result->reasons);
```

`$client->emails->verify($email)` is also available as a convenience method for single-address validation.

## Handle typo suggestions

```php theme={null}
<?php

$result = $client->verification->validate('user@gmial.com');

if ($result->isTypo && $result->suggestedEmail !== null) {
    echo 'Did you mean: ' . $result->suggestedEmail . PHP_EOL;
}
```

## Create a bulk validation job

```php theme={null}
<?php

$job = $client->verification->createBulk(__DIR__ . '/emails.csv');

echo $job->id . PHP_EOL;
echo $job->status . PHP_EOL;
echo $job->reservedCredits . PHP_EOL;
```

## List and poll jobs

```php theme={null}
<?php

$jobs = $client->verification->listBulk([
    'limit' => 20,
    'status' => 'COMPLETED',
]);

$job = $client->verification->getBulk($job->id);

var_dump($jobs->nextCursor);
var_dump($job->status, $job->readyForDownload);
```

If a job pauses because more credits are required, continue it after adding credits:

```php theme={null}
<?php

if ($job->status === 'ACTION_REQUIRED') {
    $job = $client->verification->continueBulk($job->id);
}
```

## Download results

```php theme={null}
<?php

if ($job->readyForDownload) {
    $download = $client->verification->downloadBulk($job->id, [
        'filter' => 'valid',
        'format' => 'csv',
    ]);

    file_put_contents($download->filename ?? 'valid-emails.csv', $download->contents);
}
```

Download filters are `all`, `valid`, `invalid`, `unknown`, and `catchall`. Filtered downloads are CSV only. XLS is available only when `filter` is `all`.

## Delete a job

```php theme={null}
<?php

$refundedCredits = $client->verification->deleteBulk($job->id);

echo $refundedCredits . PHP_EOL;
```

Jobs can be deleted only when they are not actively uploading or processing.

## Check credits

```php theme={null}
<?php

$credits = $client->verification->credits();
$ledger = $client->verification->ledger(['limit' => 25]);

var_dump($credits->balance, $credits->lowCredits);
var_dump(count($ledger['items']), $ledger['nextCursor']);
```

See full endpoint details in the [Email Validation API reference](https://docs.mailglyph.com/api-reference/verifications/verifyEmail.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.