Email Setup - Resend
Panduan setup layanan email dengan Resend untuk verifikasi email dan notifikasi.
📋 Overview
Resend adalah layanan email transactional modern untuk aplikasi.
Keuntungan:
- 🚀 Simple API
- 💰 Free tier: 3,000 emails/month
- 📊 Real-time analytics
- 🎨 Beautiful email templates
- 🔒 Domain verification
🚀 Setup Resend
1. Create Account
- Buka Resend
- Sign up dengan email atau GitHub
- Verify email Anda
2. Get API Key
- Dashboard Resend → API Keys
- Klik "Create API Key"
- Beri nama (contoh: "Development")
- Permission: Full access atau Sending access
- Copy API Key (format:
re_xxxxxxxx)
⚠️ Penting: API Key hanya ditampilkan sekali!
3. (Production) Verify Domain
Untuk production dengan domain sendiri:
- Dashboard → Domains
- Klik "Add Domain"
- Masukkan domain (contoh:
yourdomain.com) - Copy DNS records (SPF, DKIM, DMARC)
- Tambahkan ke DNS provider Anda
- Tunggu verification (biasanya 5-30 menit)
Untuk development: Bisa pakai onboarding@resend.dev
🔧 Konfigurasi Project
1. Update .env
env
RESEND_API_TOKEN=re_xxxxxxxxxxxx
FROM_EMAIL=noreply@yourdomain.com # atau onboarding@resend.dev2. Test Email
bash
npm run dev- Register user baru
- Check console untuk verification link
- Email akan muncul di console (development mode)
📧 Fitur Email
Email Verification
Otomatis terkirim saat user register:
To: user@example.com
Subject: Verify your email address
Hi {name},
Thanks for signing up! Click link below to verify:
https://yourdomain.com/auth/verify-email?token=xxx&email=xxxResend Verification
User bisa minta kirim ulang:
- Profile page → "Resend verification email"
- Rate limited: 1 menit interval
🎨 Email Template
Template sudah include di:
typescript
src/lib/email/templates/verification.tsFeatures:
- ✅ Responsive HTML
- ✅ Plain text fallback
- ✅ Brand colors
- ✅ Expiration warning
Custom Template
Edit src/lib/email/templates/verification.ts:
typescript
export function generateVerificationEmail(data) {
const { name, verificationUrl, expiresIn } = data;
return {
html: `...`, // Your HTML
text: `...` // Your plain text
};
}💰 Pricing
| Plan | Emails/Month | Price |
|---|---|---|
| Free | 3,000 | $0 |
| Starter | 50,000 | $20 |
| Pro | 200,000 | $80 |
🐛 Troubleshooting
| Error | Solusi |
|---|---|
| "Invalid API Key" | Check API key, pastikan re_ prefix |
| "Domain not verified" | Verifikasi domain atau pakai onboarding@resend.dev |
| "Rate limit exceeded" | Tunggu 1 menit atau upgrade plan |
| Email tidak terkirim | Check Resend dashboard → Logs |
Check Email Logs
Resend Dashboard → Logs
- Lihat status email (delivered, bounced, complained)
- Debug failed emails
- Analytics delivery
📖 Resources
Setup selesai! Email verification sekarang aktif di aplikasi Anda.