- Welcome emails on user registration
- Monthly expense summary reports
- Weekly spending reports
- Budget limit alerts
- Password reset emails (structure ready)
services/emailService.js- Complete email service with templatesservices/cronJobs.js- Automated email schedulingroutes/notifications.js- Manual email trigger endpoints- Updated
routes/auth.js- Welcome email on registration - Updated
server.js- Cron jobs initialization - Updated
package.json- Added nodemailer and node-cron - Updated
.env- Email configuration variables
- Sent automatically on user registration
- Includes getting started guide
- Professional HTML template
- Automated on 1st of every month at 10 AM
- Total income, expenses, and balance
- Top 5 spending categories
- Financial health summary
- Automated every Sunday at 9 AM
- Daily spending breakdown
- Weekly total and daily average
- Spending pattern insights
- Daily check at 8 PM
- Triggered at 80% budget usage
- Category-wise spending alerts
- Remaining budget information
- Secure reset token generation
- Time-limited reset links
- Professional email template
- POST /api/notifications/test - Send test welcome email
- POST /api/notifications/monthly-report - Generate monthly report
- POST /api/notifications/weekly-report - Generate weekly report
// Weekly reports - Every Sunday at 9 AM
'0 9 * * 0'
// Monthly reports - 1st day of month at 10 AM
'0 10 1 * *'
// Budget alerts - Daily at 8 PM
'0 20 * * *'- Install dependencies:
npm install nodemailer node-cron- Configure email in
.env:
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=[email protected]
EMAIL_PASS=your-app-password
EMAIL_FROM=ExpenseFlow <[email protected]>- Gmail Setup:
- Enable 2-factor authentication
- Generate app-specific password
- Use app password in EMAIL_PASS
- Responsive design - Works on all devices
- Brand colors - Consistent with ExpenseFlow theme
- Rich formatting - Tables, charts, and visual elements
- Call-to-action buttons - Interactive elements
- Financial data - Formatted currency and percentages
await emailService.sendWelcomeEmail(user);const reportData = {
totalExpenses: 25000,
totalIncome: 50000,
balance: 25000,
topCategories: [...]
};
await emailService.sendMonthlyReport(user, reportData);await emailService.sendBudgetAlert(user, 'food', 8500, 10000);📧 Automated Communication - Users stay informed without manual intervention
📊 Financial Insights - Regular spending analysis and trends
🎯 User Engagement - Regular touchpoints to maintain app usage
📱 Multi-channel - Email + in-app notifications
The email notification system ensures users stay connected with their financial data and receive timely insights to make better spending decisions.
Resolves: #47