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

# Emails

> Send emails and validate email addresses with the MailGlyph PHP SDK.

Use a **secret key** client for all email methods.

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

use MailGlyph\MailGlyph;

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

## Send with basic HTML (`emails->send`)

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

$result = $client->emails->send([
    'to' => 'user@example.com',
    'from' => [
        'name' => 'MailGlyph Demo',
        'email' => 'hello@your-verified-domain.com',
    ],
    'subject' => 'Welcome',
    'body' => '<h1>Hello</h1><p>Your SDK setup is working.</p>',
]);

echo $result->timestamp . PHP_EOL;
echo $result->emails[0]['email'] . PHP_EOL;
```

## Send to multiple recipients

`to` supports strings, recipient objects, or both:

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

$client->emails->send([
    'to' => [
        'one@example.com',
        ['name' => 'Two', 'email' => 'two@example.com'],
    ],
    'from' => 'hello@your-verified-domain.com',
    'subject' => 'Product update',
    'body' => '<p>New features are live.</p>',
]);
```

## Send with template and data

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

$client->emails->send([
    'to' => 'user@example.com',
    'from' => 'hello@your-verified-domain.com',
    'template' => 'tmpl_123',
    'data' => [
        'firstName' => 'John',
        'plan' => 'premium',
    ],
]);
```

## Send with attachments

Attachment content should be Base64-encoded:

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

$client->emails->send([
    'to' => 'user@example.com',
    'from' => 'billing@your-verified-domain.com',
    'subject' => 'Your invoice',
    'body' => '<p>Invoice attached.</p>',
    'attachments' => [
        [
            'filename' => 'invoice.pdf',
            'content' => 'JVBERi0xLjQKJ...',
            'contentType' => 'application/pdf',
        ],
    ],
]);
```

## Send with advanced options

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

$client->emails->send([
    'to' => ['name' => 'Jane Doe', 'email' => 'jane@example.com'],
    'from' => ['name' => 'Growth Team', 'email' => 'hello@your-verified-domain.com'],
    'subject' => 'Release notes',
    'body' => '<p>Monthly update.</p>',
    'reply' => 'support@your-verified-domain.com',
    'name' => 'Monthly newsletter',
    'subscribed' => true,
    'headers' => [
        'X-Campaign-Id' => 'monthly-2026-03',
    ],
]);
```

## Handle typo suggestions

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

$verification = $client->emails->verify('user@gmial.com');

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

For bulk validation, credits, and ledger examples, see [PHP Email Validation](https://docs.mailglyph.com/sdks/php/email-validation.md).

See full endpoint details in the [Send email API reference](https://docs.mailglyph.com/api-reference/public-api/sendEmail.md) and [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.