darvis/mailtrap
| Install | |
|---|---|
composer require darvis/mailtrap |
|
| Latest Version: | v1.4.1 |
| PHP: | ^8.2 |
| License: | MIT |
| Last Updated: | Sep 17, 2026 |
| Links: | GitHub · Packagist |
Darvis Mailtrap
Mailtrap integration for Laravel: address validation before sending, logging of every outgoing mail, delivery feedback through the Mailtrap webhook, and an inbox to inspect it all.
An independent open-source package, not an official Mailtrap product.
Features
- Validation before sending: format and MX checks on every To, Cc and Bcc address, with blocking per address
- Mail logging: every outgoing mail in
mail_logs, optionally linked to a model - Webhook: delivery, bounce, spam and reject events from Mailtrap update logs and addresses, with signature verification
- Inbox UI: a Livewire/Flux page to search, inspect and clean up logged mail
- Health check:
mailtrap:testsends a test mail, with CI-friendly exit codes - Setup wizard:
mailtrap:installconfigures tokens, SMTP, webhook and inbox - Any mailer: validation and logging also work with SES, Microsoft Graph and others
Installation
composer require darvis/mailtrap
php artisan mailtrap:install
The wizard walks you through the database, Mailtrap tokens, SMTP settings, webhook,
validation and inbox, and writes every answer to .env. Run it on every server.
Sending through Mailtrap takes two different tokens plus a webhook secret:
.env variable |
What it is | Used for |
|---|---|---|
MAIL_PASSWORD |
Token of your sending domain | Sending mail over SMTP |
MAILTRAP_API_TOKEN |
Account API token with Admin access | Creating the webhook |
MAILTRAP_WEBHOOK_SECRET |
Signing secret of the webhook | Verifying webhook calls |
See Installation & Configuration for where to find them, non-interactive installs and all configuration options.
Usage
Once installed, outgoing mail is validated and logged automatically. A blocked address
aborts the send with a TransportException.
use Darvis\Mailtrap\Models\EmailValidation;
use Darvis\Mailtrap\Models\MailLog;
// null when valid, otherwise the reason
$error = EmailValidation::validateEmail('user@example.com');
// Stop all mail to one address (never to the whole domain)
EmailValidation::markAsBlocked('complainer@example.com', 'Spam complaint');
// Query the logs
MailLog::forModel(Invoice::class, $invoice->id)->failed()->get();
php artisan mailtrap:test you@example.com
Documentation
Full documentation: https://arviddejong.github.io/mailtrap/
| Topic | |
|---|---|
| Installation & Configuration | Tokens, setup wizard, config file, environment variables |
| Sending, Blocking & Mail Logs | Validation states, linking logs to models, pruning, events, other mailers |
| Webhook | Delivery events, signature verification, mailtrap:webhook |
| Inbox UI & Health Check | Inbox setup, Tailwind, mailtrap:test |
| Email Validation | Single and bulk validation, collections, API reference, examples |
Or start at the documentation index, or read the FAQ.
Laravel Boost
The package ships Laravel Boost resources: a guideline
and a mailtrap-development skill. Run php artisan boost:install, or
php artisan boost:update --discover in a project that already uses Boost.
Development
composer test # Pest
composer lint # Pint, check only (composer format to fix)
composer analyse # Larastan
GitHub Actions runs the tests on PHP 8.2–8.4 against Laravel 11, 12 and 13, with both the lowest and the latest allowed dependencies. See the changelog for release notes.
Contributing and security
See CONTRIBUTING.md. Found a security problem? Please report it privately, see SECURITY.md.
Author
Arvid de Jong · info@arvid.nl
License
MIT, see LICENSE.
Related Packages
Complete email management for Laravel: logging, database templates with translat...
Complete email management UI for Filament: mail logs with preview, database temp...
Laravel Filemanager integration for the Flux Pro editor: insert images and file...
Blocks spam bots and Livewire payload injection in Laravel apps, keeps the resul...