Step 6: Setup MailerSend

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

  1. Open your browser and navigate to MailerSend's website (opens in a new tab)
  2. Click on "Start for free"
  3. Sign up with your email address
  4. Verify your email address

Step 2: Get Your API Token

  1. Once logged in, go to API Tokens in the left sidebar
  2. Click "Create token"
  3. Give it a name (e.g., "SaaSavant Production")
  4. Select "Full access" or specific permissions:
    • ✅ Email - Send
    • ✅ Email - Read
  5. Click "Create token"
  6. 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:

  1. In MailerSend Dashboard, go to Domains
  2. Click "Add domain"
  3. Enter your domain (e.g., yourdomain.com)
  4. Add the DNS records to your domain provider:
    • TXT record for domain verification
    • CNAME records for email authentication (SPF, DKIM)
  5. Click "Verify domain"
  6. 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:

  1. Go to RecipientsSuppression list
  2. Click "Add recipient"
  3. Enter the email address you want to test with
  4. 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

  1. ✅ Check API token is correct
  2. ✅ Verify domain is authenticated
  3. ✅ Check recipient is verified (sandbox mode)
  4. ✅ Check MailerSend dashboard for errors
  5. ✅ Review server logs for error messages

Emails Going to Spam

  1. ✅ Verify your domain properly (SPF, DKIM, DMARC)
  2. ✅ Use a professional "from" address
  3. ✅ Avoid spam trigger words
  4. ✅ Include unsubscribe link
  5. ✅ 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


🎉

You're all set! MailerSend is now configured and ready to send emails from your SaaSavant application.