Frequently asked questions

What is darvis/mailtrap?

A Laravel package that checks every recipient before a mail goes out, logs every outgoing mail in the mail_logs table, processes signed Mailtrap webhook events and adds an inbox page to the application. It hooks into Laravel’s mail events, so it works with every Mail::send() without code changes.

Is darvis/mailtrap an official Mailtrap package?

No. It is an unofficial, independent open-source package under the MIT license, maintained by ARVID.NL. It is not made, supported or endorsed by Mailtrap.

How do I log every outgoing email in Laravel?

Run composer require darvis/mailtrap and php artisan migrate. Every mail the application sends is then logged in the mail_logs table, one row per recipient, and can be linked to a model with the X-Mail-Model and X-Mail-Model-ID headers.

Does darvis/mailtrap only work when I send through Mailtrap, and what does it cost?

No. Recipient validation, mail logging and the inbox page work with any Laravel mailer and need no Mailtrap account. Only the delivery feedback through the webhook needs Mailtrap Email Sending. The package itself is free.

Which PHP, Laravel and Livewire versions does darvis/mailtrap support?

PHP 8.2 or higher and Laravel 11, 12 and 13. Only the inbox page needs Livewire ^3.7.4 or ^4.0 and Flux ^2.11 (the free edition); without them the rest of the package works.

How does darvis/mailtrap validate an email address?

It checks the format, then looks up an MX record for the domain that resolves to an IP address, and stores the verdict in the email_validations table. It does not connect to the mail server and does not call Mailtrap, so it cannot tell whether the mailbox exists.

How do I stop sending email to one address in Laravel?

Call EmailValidation::markAsBlocked($email, $reason). A send to that address is aborted with a Symfony TransportException and logged with status 550; other addresses on the same domain are not affected. EmailValidation::markAsValid($email) lifts the block.

Does a bounce block future mail to that address?

No. Bounce, spam and reject events mark the address as invalid, which is recorded but does not stop sending. Only the verdict blocked stops a send.

How is the Mailtrap webhook secured?

The endpoint POST /api/webhooks/mailtrap compares an HMAC-SHA256 of the raw request body, keyed with MAILTRAP_WEBHOOK_SECRET, to the Mailtrap-Signature header. A call without a valid signature gets 403, and so does every call while no secret is configured.

Who can open the darvis/mailtrap inbox page?

Outside the local environment nobody, until the application defines the viewMailtrap gate, the way Laravel Horizon does it. For example Gate::define('viewMailtrap', fn (?User $user) => $user?->is_admin === true); in AppServiceProvider::boot(). The middleware from MAILTRAP_UI_MIDDLEWARE runs before the gate, and MAILTRAP_UI_ENABLED=false removes the page.