Cap uses email for passwordless authentication. Without email configured, login links appear in server logs. This guide shows how to set up email delivery using Resend.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/CapSoftware/Cap/llms.txt
Use this file to discover all available pages before exploring further.
Why Email Configuration Matters
Without email:- Users must access server logs to get login links
- No password reset emails
- No notification emails
- Poor user experience
- One-click login from inbox
- Professional user experience
- Notification support
- Production-ready authentication
Resend (Recommended)
Resend is Cap’s officially supported email provider.Why Resend?
- Simple API and setup
- Generous free tier (3,000 emails/month)
- Excellent deliverability
- Built for developers
- No credit card required for trial
Setup Steps
Create Resend Account
- Go to resend.com
- Click Sign Up
- Verify your email address
- Complete onboarding
Add and Verify Domain
- Go to Domains in Resend dashboard
- Click Add Domain
- Enter your domain (e.g.,
yourdomain.com) - Add the DNS records shown:
DNS changes can take up to 48 hours to propagate, but usually complete within minutes.
Verify Domain
- After adding DNS records, click Verify in Resend
- Wait for verification to complete
- Status should show Verified
Verification Failed?
Verification Failed?
- Wait 5-10 minutes and try again
- Use DNS checker to verify records propagated
- Ensure records match exactly (no extra quotes or spaces)
- Check with your DNS provider’s support
Create API Key
- Go to API Keys
- Click Create API Key
- Configure:
- Name: Cap Production
- Permission: Full Access (or Sending Access)
- Domain: Select your verified domain
- Copy the API key (starts with
re_)
Configure Cap
Add these environment variables to your The from address will be:
.env file:.env
noreply@yourdomain.comUsing a Subdomain
If you can’t add DNS records to your main domain, use a subdomain:Custom From Address
Change the sender name and email:This requires code modification. Cap currently uses
noreply@ as the sender.- Fork the Cap repository
- Edit
apps/web/app/api/auth/[...nextauth]/route.ts - Find the Resend email configuration
- Change
fromfield: - Rebuild and deploy
Email Template Customization
Cap uses default NextAuth email templates. To customize:- Create custom email templates
- Modify the NextAuth configuration in
apps/web/app/api/auth/[...nextauth]/route.ts - Add custom HTML/text templates
Alternative Email Providers
While Resend is recommended, Cap can work with other providers using SMTP.Using SMTP
To use SMTP providers (SendGrid, Mailgun, Postmark, etc.):- Modify NextAuth configuration to use SMTP
-
Update
apps/web/app/api/auth/[...nextauth]/route.ts: -
Add environment variables:
.env
Monitoring Email Delivery
Resend Dashboard
- Go to Resend Dashboard
- View all sent emails
- Check delivery status:
- Delivered - Successfully delivered
- Bounced - Invalid email address
- Complained - Marked as spam
- Queued - Being processed
Cap Logs
Check Cap logs for email sending:Troubleshooting
No Email Received
Check Spam Folder
Check Spam Folder
Login emails might be filtered as spam initially. Mark as “Not Spam” to improve deliverability.
Verify Domain
Verify Domain
- Go to Resend dashboard
- Check domain status is Verified
- Re-verify if needed
Check API Key
Check API Key
Test Resend API
Test Resend API
Test API key directly:Successful response:
Emails Go to Spam
Verify SPF, DKIM, DMARC
Ensure all DNS records are properly configured:
- SPF: Authorizes Resend to send from your domain
- DKIM: Cryptographic signature for authenticity
- DMARC: Policy for handling failed authentication
Warm Up Domain
New domains have poor reputation. Gradually increase sending volume:
- Day 1: 10-20 emails
- Day 2: 50 emails
- Week 1: 100/day
- Week 2: 500/day
- After month: Full volume
Monitor Bounce Rate
Keep bounce rate below 5%:
- Remove invalid email addresses
- Use double opt-in for signups
- Monitor Resend dashboard for bounces
Rate Limiting
Resend free tier limits:- 3,000 emails/month
- 100 emails/day (first month)
- Check Resend dashboard for current usage
- Upgrade to paid plan ($20/month for 50,000 emails)
- Or implement email queue to spread sends
Invalid API Key Error
- Verify
RESEND_API_KEYin.envis correct - Key should start with
re_ - Ensure no extra spaces or quotes
- Create new API key if needed
- Restart Cap after changing
Production Best Practices
Security
- Never commit API keys to git
- Use environment variables only
- Rotate API keys periodically
- Use separate keys for staging/production
- Enable 2FA on Resend account
Deliverability
- Always verify your domain
- Configure all DNS records (SPF, DKIM, DMARC)
- Monitor bounce and complaint rates
- Keep email list clean
- Use descriptive from names
- Include physical address in footer (legal requirement in some regions)
Monitoring
- Set up Resend webhooks for delivery events
- Monitor email sending in logs
- Track bounce and complaint rates
- Set up alerts for failed sends
- Review Resend analytics monthly
Webhooks (Advanced)
Receive real-time delivery notifications:Configure in Resend
- Go to Webhooks in Resend
- Click Add Webhook
- URL:
https://cap.yourdomain.com/api/webhooks/resend - Select events: delivered, bounced, complained
Cost Estimation
Resend Pricing:| Tier | Price | Emails/month | Best For |
|---|---|---|---|
| Free | $0 | 3,000 | Testing, small teams |
| Pro | $20 | 50,000 | Small businesses |
| Business | $80 | 250,000 | Growing companies |
| Enterprise | Custom | Custom | Large deployments |
- Login emails: ~1-3 per user per month
- 100 users = ~300 emails/month
- 1,000 users = ~3,000 emails/month (Free tier)
- 10,000 users = ~30,000 emails/month (Pro tier)
Next Steps
Environment Variables
Complete email configuration reference
SSL/HTTPS
Secure your deployment
Troubleshooting
Debug email issues
Scaling
Scale email for production