Setting Up MailerSend and Configuring Your API Key
New in v2.2! SaaSavant now uses MailerSend instead of SendGrid. MailerSend offers 12,000 free emails per month with no credit card required!
Why MailerSend?
SendGrid removed their free tier, but MailerSend provides an excellent alternative:
- ✅ 12,000 emails/month free (vs SendGrid's $0)
- ✅ No credit card required for free tier
- ✅ Email analytics and tracking included
- ✅ Template management
- ✅ Easy API integration
Step 1: Create a MailerSend Account
- Open your browser and navigate to MailerSend's website (opens in a new tab)
- Click on "Start for free"
- Sign up with your email address
- Verify your email address
Step 2: Get Your API Token
- Once logged in, go to API Tokens in the left sidebar
- Click "Create token"
- Give it a name (e.g., "SaaSavant Production")
- Select "Full access" or specific permissions:
- ✅ Email - Send
- ✅ Email - Read
- Click "Create token"
- Copy the token (starts with
mlsn.
)
Important: Save this token securely - you won't be able to see it again!
Step 3: Configure Your Domain (Optional for Development)
For Development/Testing:
You can use the sandbox domain provided by MailerSend:
- No domain verification needed for testing
- Emails will only be sent to verified recipients
- Find your trial domain in: Dashboard → Domains
For Production:
- In MailerSend Dashboard, go to Domains
- Click "Add domain"
- Enter your domain (e.g.,
yourdomain.com
) - Add the DNS records to your domain provider:
- TXT record for domain verification
- CNAME records for email authentication (SPF, DKIM)
- Click "Verify domain"
- Wait for verification (usually 5-30 minutes)
Step 4: Add Your API Key to .env.local
Open your project's root directory and locate the .env.local
file (or create one if it doesn't exist).
Add your MailerSend API key:
MAILERSEND_API_KEY=mlsn.your_api_token_here
MAILERSEND_FROM_EMAIL=noreply@yourdomain.com
For Development:
MAILERSEND_API_KEY=mlsn.your_api_token_here
MAILERSEND_FROM_EMAIL=noreply@trial-xxxxx.mlsender.net
(Use the sandbox domain from your MailerSend dashboard)
Step 5: Verify Recipients (Development Only)
If using the sandbox domain, you need to verify recipient emails:
- Go to Recipients → Suppression list
- Click "Add recipient"
- Enter the email address you want to test with
- Verify the email address
Testing Your Setup
Test Welcome Email
Start your development server:
npm run dev
Then test the welcome email API:
macOS/Linux:
curl -X POST http://localhost:3000/api/sendWelcomeEmail \
-H "Content-Type: application/json" \
-d '{"email":"your-test-email@example.com"}'
Windows (PowerShell):
Invoke-RestMethod -Uri http://localhost:3000/api/sendWelcomeEmail `
-Method POST `
-Headers @{"Content-Type"="application/json"} `
-Body '{"email":"your-test-email@example.com"}'
Test Newsletter
macOS/Linux:
curl -X POST http://localhost:3000/api/sendNewsletter \
-H "Content-Type: application/json" \
-d '{
"emails": ["test@example.com"],
"subject": "Test Newsletter",
"html": "<h1>Hello World!</h1><p>This is a test newsletter.</p>"
}'
Windows (PowerShell):
$body = @{
emails = @("test@example.com")
subject = "Test Newsletter"
html = "<h1>Hello World!</h1><p>This is a test newsletter.</p>"
} | ConvertTo-Json
Invoke-RestMethod -Uri http://localhost:3000/api/sendNewsletter `
-Method POST `
-Headers @{"Content-Type"="application/json"} `
-Body $body
Production Setup
Use Your Own Domain
For production, always use your verified domain:
MAILERSEND_FROM_EMAIL=noreply@yourdomain.com
Create a Production API Token
Create a separate token for production with appropriate permissions.
Monitor Your Usage
- Dashboard shows email statistics
- Free tier: 12,000 emails/month
- Upgrade if you need more
Troubleshooting
Emails Not Sending
- ✅ Check API token is correct
- ✅ Verify domain is authenticated
- ✅ Check recipient is verified (sandbox mode)
- ✅ Check MailerSend dashboard for errors
- ✅ Review server logs for error messages
Emails Going to Spam
- ✅ Verify your domain properly (SPF, DKIM, DMARC)
- ✅ Use a professional "from" address
- ✅ Avoid spam trigger words
- ✅ Include unsubscribe link
- ✅ Warm up your domain gradually
Rate Limits
Free tier limits:
- 12,000 emails/month
- 100 emails/hour (burst)
If you hit limits, consider upgrading or implementing email queuing.
Additional Resources
- Documentation: https://developers.mailersend.com/ (opens in a new tab)
- API Reference: https://developers.mailersend.com/api/v1/email.html (opens in a new tab)
- Support: https://www.mailersend.com/help (opens in a new tab)
- Status Page: https://status.mailersend.com/ (opens in a new tab)
You're all set! MailerSend is now configured and ready to send emails from your SaaSavant application.