Mailpit Setup
Mailpit captures all outgoing emails in local development, providing a web UI to view and test email notifications without actual delivery.
What is Mailpit
Section titled “What is Mailpit”Mailpit is a lightweight SMTP server and web UI for testing emails locally:
- Captures all outgoing SMTP emails
- Web interface to view email content
- No emails actually delivered to real addresses
- Perfect for notification development and testing
Website: https://mailpit.axllent.org
Configuration
Section titled “Configuration”Docker Compose
Section titled “Docker Compose”Mailpit service already configured in docker-compose.yml:
mailpit: image: 'axllent/mailpit:latest' ports: - '${FORWARD_MAILPIT_PORT:-1025}:1025' # SMTP port - '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025' # Web UI port networks: - sailSource: backend/docker-compose.yml:101-107
Environment Variables
Section titled “Environment Variables”Add to .env:
MAIL_MAILER=smtpMAIL_HOST=mailpitMAIL_PORT=1025MAIL_FROM_ADDRESS="noreply@volare.test"MAIL_FROM_NAME="Volare"
# Optional: Custom portsFORWARD_MAILPIT_PORT=1025FORWARD_MAILPIT_DASHBOARD_PORT=8025Default .env.example uses MAIL_MAILER=log - update for email testing.
Start Mailpit
Section titled “Start Mailpit”Mailpit starts automatically with Sail:
./vendor/bin/sail up -dAccess Web UI
Section titled “Access Web UI”Open browser: http://localhost:8025
Features:
- View all captured emails
- Search by recipient, subject, date
- View HTML and plain text versions
- Inspect email headers
- Test responsive email templates
Send Test Notification
Section titled “Send Test Notification”# Send to first user./vendor/bin/sail artisan notification:test
# Send to specific email./vendor/bin/sail artisan notification:test admin@example.comCheck Mailpit UI to see delivered email.
Trigger from Application
Section titled “Trigger from Application”Any Laravel notification with ‘mail’ channel sends to Mailpit:
$user->notify(new OfferCreatedNotification($offer));Queue worker must be running:
./vendor/bin/sail artisan queue:work| Service | Port | URL |
|---|---|---|
| Web UI | 8025 | http://localhost:8025 |
| SMTP | 1025 | mailpit:1025 (internal) |
Port conflicts: Update FORWARD_MAILPIT_* env vars if needed.
Testing Email Notifications
Section titled “Testing Email Notifications”1. Start Services
Section titled “1. Start Services”./vendor/bin/sail up -d./vendor/bin/sail artisan queue:work2. Trigger Notification
Section titled “2. Trigger Notification”Create offer, booking, or use test command.
3. View in Mailpit
Section titled “3. View in Mailpit”- Open http://localhost:8025
- Find email in list
- Click to view full content
- Verify subject, body, formatting
- Test action buttons
4. Verify Content
Section titled “4. Verify Content”Check:
- Subject line clear and specific
- Greeting personalized with user name
- Content formatted correctly (markdown rendered)
- Action buttons link correctly
- Footer includes sender info
Troubleshooting
Section titled “Troubleshooting”Mailpit UI not accessible:
- Check Docker container:
sail ps - Verify port 8025 not in use
- Check
FORWARD_MAILPIT_DASHBOARD_PORTin .env
Emails not appearing:
- Queue worker running?
sail artisan queue:work - Check MAIL_HOST=mailpit in .env
- View logs:
sail logs mailpit - Verify notification uses ‘mail’ channel
SMTP connection refused:
- Container running?
sail ps - Check MAIL_PORT=1025
- Mailpit service in docker-compose depends_on
Production Configuration
Section titled “Production Configuration”Never use Mailpit in production.
Production .env should use real SMTP:
MAIL_MAILER=smtpMAIL_HOST=smtp.mailtrap.ioMAIL_PORT=2525MAIL_USERNAME=your_usernameMAIL_PASSWORD=your_passwordMAIL_FROM_ADDRESS="noreply@volare.com"MAIL_FROM_NAME="Volare"Or use service-specific mailer:
MAIL_MAILER=sesfor AWS SESMAIL_MAILER=sendmailfor server sendmailMAIL_MAILER=mailgunfor Mailgun
Alternative: Log Mailer
Section titled “Alternative: Log Mailer”For quick local dev without email UI:
MAIL_MAILER=logEmails written to storage/logs/laravel.log instead of Mailpit.
Less convenient than Mailpit UI but no additional service needed.