Local Email Development with Mailpit
Test email functionality locally using Mailpit. Capture authentication emails, team invitations, and transactional emails without sending real messages.
When developing locally, Supabase automatically runs Mailpit (or InBucket in older versions) to capture all emails. This lets you test email flows without configuring an email provider or sending real emails.
Accessing Mailpit
With Supabase running locally, open Mailpit at:
http://localhost:54324All emails sent during development appear here, including:
- Supabase Auth emails (verification, password reset, magic links)
- MakerKit transactional emails (team invitations, account notifications)
- Any custom emails you send via the mailer
How It Works
The local Supabase setup configures both Supabase Auth and MakerKit to use the local SMTP server:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐│ Your App │────▶│ Local SMTP │────▶│ Mailpit UI ││ (Auth + Mailer)│ │ (port 54325) │ │ (port 54324) │└─────────────────┘ └─────────────────┘ └─────────────────┘The default development environment variables in apps/web/.env.development point to this local SMTP:
EMAIL_HOST=127.0.0.1EMAIL_PORT=54325EMAIL_USER=EMAIL_PASSWORD=EMAIL_TLS=falseEMAIL_SENDER=test@makerkit.devTesting Common Flows
Email Verification
- Start your dev server:
pnpm dev - Sign up with any email address (e.g.,
test@example.com) - Open http://localhost:54324
- Find the verification email
- Click the verification link
Password Reset
- Go to the sign-in page
- Click "Forgot password"
- Enter any email address
- Check Mailpit for the reset email
- Click the reset link to set a new password
Magic Link Login
- Go to the sign-in page
- Enter an email and request a magic link
- Check Mailpit for the magic link email
- Click the link to sign in
Team Invitations
- Sign in and navigate to team settings
- Invite a new member by email
- Check Mailpit for the invitation email
- Use the invitation link to accept
Using a Real Email Provider Locally
If you need to test with a real email provider during development (e.g., to test email rendering in actual clients), override the development environment variables:
apps/web/.env.development.local
# Override to use Resend locallyMAILER_PROVIDER=resendRESEND_API_KEY=re_your-test-keyEMAIL_SENDER=YourApp <test@yourdomain.com>Or for SMTP:
apps/web/.env.development.local
# Override to use real SMTP locallyEMAIL_HOST=smtp.your-provider.comEMAIL_PORT=587EMAIL_USER=your-usernameEMAIL_PASSWORD=your-passwordEMAIL_TLS=trueEMAIL_SENDER=YourApp <test@yourdomain.com>Supabase Auth Emails
Even with a custom email provider, Supabase Auth emails (verification, password reset) still go through Mailpit. To test Supabase Auth emails with a real provider, you need to configure SMTP in the Supabase dashboard.
Debugging Email Issues
Emails Not Appearing in Mailpit
If emails don't show up:
- Verify Supabase is running: Check
supabase status - Check the port: Mailpit runs on port 54324, SMTP on 54325
- Check environment variables: Ensure
EMAIL_HOST=127.0.0.1andEMAIL_PORT=54325 - Check server logs: Look for SMTP connection errors in your terminal
Wrong Email Content
If emails appear but content is wrong:
- Check template rendering: Templates are rendered at send time
- Verify template data: Log the data passed to
renderXxxEmail()functions - Check i18n: Ensure translation files exist for your locale
Links Not Working
If email links don't work when clicked:
- Check
NEXT_PUBLIC_SITE_URL: Should behttp://localhost:3000for local dev - Verify route exists: The link destination route must be implemented
- Check token handling: For auth emails, ensure
/auth/confirmroute works
Mailpit Features
Mailpit provides useful features for testing:
Search and Filter
Filter emails by:
- Sender address
- Recipient address
- Subject line
- Date range
View HTML and Plain Text
Toggle between:
- HTML rendered view
- Plain text view
- Raw source
Check Headers
Inspect email headers for:
- Content-Type
- MIME structure
- Custom headers
API Access
Mailpit has an API for programmatic access:
# List all messagescurl http://localhost:54324/api/v1/messages# Get specific messagecurl http://localhost:54324/api/v1/message/{id}# Delete all messagescurl -X DELETE http://localhost:54324/api/v1/messagesProduction Checklist
Before deploying, ensure you've:
- Configured a production email provider: Set
MAILER_PROVIDER, API keys, and SMTP credentials - Verified sender domain: Set up SPF, DKIM, and DMARC records
- Updated Supabase Auth templates: Replace default templates with token-hash versions
- Tested real email delivery: Send test emails to verify deliverability
- Set up monitoring: Configure alerts for email delivery failures