Skip to main content
Use a secret key client for all email methods.
<?php

use Mailrify\Mailrify;

$client = new Mailrify($_ENV['MAILRIFY_SECRET_KEY']);

Send with basic HTML (emails->send)

<?php

$result = $client->emails->send([
    'to' => '[email protected]',
    'from' => [
        'name' => 'Mailrify Demo',
        'email' => '[email protected]',
    ],
    '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

$client->emails->send([
    'to' => [
        '[email protected]',
        ['name' => 'Two', 'email' => '[email protected]'],
    ],
    'from' => '[email protected]',
    'subject' => 'Product update',
    'body' => '<p>New features are live.</p>',
]);

Send with template and data

<?php

$client->emails->send([
    'to' => '[email protected]',
    'from' => '[email protected]',
    'template' => 'tmpl_123',
    'data' => [
        'firstName' => 'John',
        'plan' => 'premium',
    ],
]);

Send with attachments

Attachment content should be Base64-encoded:
<?php

$client->emails->send([
    'to' => '[email protected]',
    'from' => '[email protected]',
    'subject' => 'Your invoice',
    'body' => '<p>Invoice attached.</p>',
    'attachments' => [
        [
            'filename' => 'invoice.pdf',
            'content' => 'JVBERi0xLjQKJ...',
            'contentType' => 'application/pdf',
        ],
    ],
]);

Send with advanced options

<?php

$client->emails->send([
    'to' => ['name' => 'Jane Doe', 'email' => '[email protected]'],
    'from' => ['name' => 'Growth Team', 'email' => '[email protected]'],
    'subject' => 'Release notes',
    'body' => '<p>Monthly update.</p>',
    'reply' => '[email protected]',
    'name' => 'Monthly newsletter',
    'subscribed' => true,
    'headers' => [
        'X-Campaign-Id' => 'monthly-2026-03',
    ],
]);

Verify an email address (emails->verify)

<?php

$verification = $client->emails->verify('[email protected]');

var_dump($verification->valid);
var_dump($verification->isRandomInput);
var_dump($verification->reasons);

Handle typo suggestions

<?php

$verification = $client->emails->verify('[email protected]');

if ($verification->isTypo && $verification->suggestedEmail !== null) {
    echo 'Did you mean: ' . $verification->suggestedEmail . PHP_EOL;
}
See full endpoint details in the Send email API reference and Verify email API reference.