← All use cases

QA & Staging Environments

Test email sending without reaching real recipients

Use MailBrew addresses as recipients to test email functionality without reaching real customers. Create addresses through the API, then retrieve and check the emails sent to them. You can also point your app's SMTP server setting at MailBrew.

What you can do with MailBrew

  1. 01

    Kept away from real recipients

    Mail to MailBrew addresses is received by MailBrew and not delivered to the original recipients. To catch recipients you forgot to replace, combine it with a check in your app that stops the send.

  2. 02

    Capture mail for any recipient

    When your SMTP server setting points at MailBrew, mail sent with SMTP authentication is received whatever the recipient, and you can look it up by the original recipient (?to=) through the API.

  3. 03

    Check what was sent

    Subject, sender, recipients, and HTML/text body are available through the REST API. The raw source (including headers) is available at /raw and attachments at /attachments, and both can also be checked in the dashboard Mailbox.

  4. 04

    Share with QA

    Instead of handing out API keys, add QA staff as members with the Mailbox only role so they can open received emails in the Mailbox.

Sample code

PHP (Laravel / PHPUnit)

PHP (Laravel / PHPUnit)
<?php
use Illuminate\Support\Facades\Http;

$apiKey = env('MAILBREW_API_KEY');
$base = 'https://mailbrew.dev/api/mailbrew';

// 1. Create a test address (ttl in seconds)
$addr = Http::withHeaders(['X-API-Key' => $apiKey])
    ->post("$base/addresses", ['ttl' => 600])
    ->json()['data'];

// 2. Place an order so the app sends a confirmation email (point the test mailer at real SMTP; Mail::fake or the array mailer never sends)
$this->post('/api/orders', [
    'customer_email' => $addr['address'],
    'items' => [['product_id' => 1, 'qty' => 2]],
]);

// 3. Wait for the email (timeout in seconds, max 60)
$emails = Http::withHeaders(['X-API-Key' => $apiKey])
    ->timeout(40)
    ->get("$base/addresses/{$addr['address']}/emails/wait", ['timeout' => 30])
    ->json()['data'];

$this->assertCount(1, $emails);
$this->assertEquals('Order Confirmation', $emails[0]['subject']);

Ready to try this use case?

Get started with the free plan today. No credit card required.
Free plan: up to 100 emails/month and 5 addresses

Create free account →