📧 Mailer Module
Universal email system with auto-detection for Resend and Nodemailer, email templates, and testing components.
Auto-Detection
Automatically detects and uses Resend or Nodemailer
Email Templates
Pre-built templates for common email types
Multiple Providers
Resend, SMTP, Gmail, and more
Testing Components
Built-in email testing and validation
React Hooks
useMailer hook for easy email sending
Server Actions
Email event handlers and analytics
npx shadcn@latest add "https://supremetoolkit.in/r/mailer-module"
This installs:
- • Universal mailer with auto-detection
- • Resend and Nodemailer implementations
- • Pre-built email templates
- • useMailer hook for React components
- • Email testing and validation components
- • Server actions for email events
- • Required dependencies (resend, nodemailer, @react-email/components)
Choose Your Email Provider
The mailer module automatically detects which provider to use based on your environment variables. Configure one of the options below:
1. Get Resend API Key:
Sign up at resend.com and create an API key
# .env.local
RESEND_API_KEY=re_your_api_key_here
MailerTest
Email testing component with configuration validation
EmailTemplates
Pre-built email template components
Universal Mailer
Auto-detecting email service
Auto-Detection Priority
The mailer automatically detects and uses providers in this order:
- 1. Resend - if RESEND_API_KEY is set
- 2. Nodemailer - if SMTP/Gmail config is set
- 3. Fallback - defaults to Resend with warning
1. Environment Variables (Resend):
# .env.local - Resend Configuration (Recommended)
RESEND_API_KEY=re_your_api_key_here
EMAIL_FROM=noreply@yourdomain.com
2. Environment Variables (SMTP):
# .env.local - SMTP Configuration
EMAIL_PROVIDER=smtp
SMTP_HOST=smtp.yourdomain.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=your-email@yourdomain.com
SMTP_PASSWORD=your-password
EMAIL_FROM=noreply@yourdomain.com
3. Environment Variables (Gmail):
# .env.local - Gmail Configuration
EMAIL_PROVIDER=gmail
GMAIL_USER=your-email@gmail.com
GMAIL_APP_PASSWORD=your-16-character-app-password
EMAIL_FROM=your-email@gmail.com
Provider Choice
Use Resend for modern applications - it's more reliable and easier to set up than traditional SMTP.
Environment Variables
Always use environment variables for API keys and credentials. Never commit them to version control.
Email Templates
Use the pre-built templates for consistency and better deliverability. Customize them to match your brand.
Testing
Always test your email configuration before deploying. Use the MailerTest component during development.
Error Handling
Implement proper error handling and logging for email failures. Consider retry mechanisms for critical emails.