>_SMTPBoxDOCUMENTATION

Automated email testing with the SMTPBox API

Trigger an application email, wait for a matching recipient and subject, and assert the captured message in automated tests.

09 / TEST

Test a complete email path

Use a unique recipient or subject on each run, trigger the application action, then wait for the matching message. This avoids fixed sleeps and prevents one parallel test from reading another test's email.

PHP integration test
<?php

$recipient = 'reset+' . bin2hex(random_bytes(6)) . '@example.test';
triggerPasswordReset($recipient);

$query = http_build_query([
    'timeout' => 20,
    'to' => $recipient,
    'subject' => 'Reset your password',
]);

$request = curl_init(
    "https://api.smtpbox.dev/v1/inboxes/{$inboxId}/messages/wait?{$query}"
);
curl_setopt_array($request, [
    CURLOPT_HTTPHEADER => ["Authorization: Bearer {$apiKey}"],
    CURLOPT_RETURNTRANSFER => true,
]);

$response = json_decode((string) curl_exec($request), true);
assert($response['success'] === true);
assert(str_contains($response['data']['recipients'], $recipient));
A reliable testing pattern

Create a separate inbox and API key for CI, generate unique correlation data, wait only after triggering the action, assert the body or link you need, then delete the message when isolation matters.

Updated