This guide explains how to set up email notifications for feature suggestion approvals and rejections.
When an admin approves or rejects a feature suggestion, the system will automatically send an email notification to the user who submitted the suggestion.
The system includes two email templates:
- Approval Email - Sent when a suggestion is approved and converted to a feature
- Rejection Email - Sent when a suggestion is rejected
Both templates are bilingual (English/Vietnamese) and include:
- Beautiful HTML design with gradient headers
- Clear call-to-action buttons
- Plain text fallback for email clients that don't support HTML
The system supports two email service providers:
Resend is a modern email API service with a generous free tier.
Setup Steps:
- Sign up at resend.com
- Verify your domain (or use their testing domain for development)
- Create an API key
- Add the API key to your Cloudflare Worker secrets:
wrangler secret put RESEND_API_KEYFree Tier: 3,000 emails/month, 100 emails/day
SendGrid is a popular email service provider.
Setup Steps:
- Sign up at sendgrid.com
- Verify your domain
- Create an API key with "Mail Send" permissions
- Add the API key to your Cloudflare Worker secrets:
wrangler secret put SENDGRID_API_KEYFree Tier: 100 emails/day
Choose one of the email services above and set the corresponding secret:
# For Resend
wrangler secret put RESEND_API_KEY
# OR for SendGrid
wrangler secret put SENDGRID_API_KEYEdit worker/src/utils/email.ts and update the sender email addresses:
For Resend (line 42):
from: 'Feature Voting <noreply@update.nginxwaf.me>',For SendGrid (line 67):
from: { email: 'noreply@update.nginxwaf.me', name: 'Feature Voting' },Important: Make sure the sender domain is verified with your email service provider.
The email templates use APP_URL to generate links. Verify it's set correctly in wrangler.toml:
[vars]
APP_URL = "https://idea.nginxwaf.me"If no email service API key is configured, the system will log email details to the console instead of sending actual emails. This is useful for development and testing.
You'll see logs like:
📧 Email would be sent to: user@example.com
📧 Subject: 🎉 Your Feature Suggestion Has Been Approved!
📧 Full email preview: ...
- Configure an email service (Resend or SendGrid)
- Create a test user account
- Submit a feature suggestion as that user
- Login as admin and approve/reject the suggestion
- Check the user's email inbox
Subject: 🎉 Your Feature Suggestion Has Been Approved!
Content:
- Congratulatory message
- Feature title (English and Vietnamese)
- Link to view the created feature
- Encouragement to submit more suggestions
Subject: 📋 Update on Your Feature Suggestion
Content:
- Polite notification of rejection
- Feature title (English and Vietnamese)
- Common reasons for rejection
- Encouragement to submit more suggestions
- Link to submit another suggestion
-
Check API Key: Ensure the API key is set correctly:
wrangler secret list
-
Check Logs: View Worker logs for error messages:
wrangler tail
-
Verify Domain: Make sure your sender domain is verified with the email service
-
Check Rate Limits: Ensure you haven't exceeded the free tier limits
- Verify Domain: Use a verified domain instead of a generic email
- SPF/DKIM Records: Configure proper DNS records (your email service will provide these)
- Sender Reputation: Use a consistent sender address
- Never commit API keys - Always use Wrangler secrets
- Use environment-specific keys - Different keys for development and production
- Rotate keys regularly - Change API keys periodically
- Monitor usage - Check your email service dashboard for unusual activity
Both Resend and SendGrid offer generous free tiers that should be sufficient for most small to medium projects:
- Resend: 3,000 emails/month free
- SendGrid: 100 emails/day free (3,000/month)
For higher volumes, check the pricing pages:
Consider implementing these features in the future:
- Email Preferences: Allow users to opt-out of notifications
- Digest Emails: Send weekly summaries instead of individual emails
- Rich Notifications: Include more context about why a suggestion was rejected
- Admin Notifications: Notify admins when new suggestions are submitted
- Localized Emails: Send emails in the user's preferred language only
For issues or questions:
- Check the Resend Documentation
- Check the SendGrid Documentation
- Review Worker logs:
wrangler tail - Open an issue in the project repository