Appearance
Mailgun
Learn how to set up and use Mailgun for sending emails in your application.
SaasPilot comes configured with Resend by default, but you can easily switch to Mailgun. An email provider is required for essential features such as email verification, password resets, and other transactional emails.
Overview
Mailgun is a powerful email service designed for developers. It offers reliable email delivery, detailed analytics, and excellent deliverability rates. It's particularly well-suited for applications that need to send high volumes of transactional emails.
Setup
1. Create a Mailgun Account
- Visit Mailgun and click Sign Up
- Complete the registration process
- Verify your email address
- Log in to your Mailgun dashboard
2. Add and Verify Your Domain
- In the Mailgun dashboard, navigate to Sending → Domains
- Click Add New Domain
- Enter your domain name (e.g.,
yourdomain.com) - Choose your region (US or EU)
- Click Add Domain
Verify Your Domain
Mailgun will provide you with DNS records that need to be added to your domain:
- Copy the DNS records shown in the Mailgun dashboard
- Log in to your domain registrar (where you bought your domain)
- Find the DNS settings section
- Add the following records:
- TXT records for domain verification
- MX records for receiving emails (optional)
- CNAME records for tracking
- Wait for DNS propagation (can take up to 48 hours, but usually much faster)
- Return to Mailgun and click Verify DNS Settings
3. Get Your API Credentials
- In the Mailgun dashboard, go to Settings → API Keys
- Find your Private API Key (it starts with
key-) - Copy this key - you'll need it for your configuration
- Note your Domain Name from the Domains page
4. Configure Environment Variables
Add your Mailgun credentials to your .env file:
txt
MAILGUN_API_KEY=""
MAILGUN_DOMAIN=""