SetupEmail Setup
Mailgun Setup
Learn how to set up Mailgun for reliable email delivery
Setting Up Mailgun 📧
This guide will help you set up Mailgun for reliable email delivery in your application.
Prerequisites 📋
- A Mailgun account
- Access to your domain's DNS settings
- Domain verified in Mailgun
- API key with sending permissions
Domain Verification 🔍
- Go to Mailgun Dashboard
- Navigate to Sending > Domains > Add New Domain
- Follow the DNS verification steps
- Add the provided DNS records (SPF, DKIM, DMARC) to your domain
Implementation 💻
Install required dependencies:
Create src/lib/email/sendMail.ts
:
Environment Variables 🔐
Add these to your .env.local
:
Testing Email Setup 🧪
- Send a test email using Mailgun dashboard
- Monitor delivery in Mailgun logs
- Check email headers for proper authentication
- Use the Mailgun Email Test feature
Important Notes ⚠️
- DNS propagation takes time (24-48 hours)
- Start with sandbox domain for testing
- Monitor email reputation in Mailgun dashboard
- Keep bounce rate below 5%
- Use production API key in production
Remember to wait for DNS propagation before testing your email setup. Rushing this process can lead to delivery issues! 🚀