Overview
DEMET Backend uses Nodemailer with Gmail SMTP to send automated email notifications for reservation requests, status updates, and administrative alerts.Email Service Architecture
The email system consists of three main components:Email Service Implementation
The core email service is located inservice/email.service.js:
Configuration
Gmail Setup
Enable 2-Factor Authentication
Go to Google Account Security and enable 2FA
Generate App Password
- Visit App Passwords
- Select app: Mail
- Select device: Other (Custom name)
- Enter name: DEMET Backend
- Click Generate
- Copy the 16-character password
Alternative SMTP Providers
You can also use other SMTP providers:Email Templates
The system includes three main email templates:1. Registration Request Template
Sent to customers when they submit a reservation request.The template uses inline CSS for maximum email client compatibility and includes a WhatsApp contact button.
2. Admin Notification Template
Sent to administrators when a new reservation request is submitted.3. Status Update Template
Sent when a reservation request status changes.Use Cases
1. New Reservation Request
When a customer submits a reservation request:2. Status Update Notification
Email Template Best Practices
Inline CSS
Always use inline styles for maximum email client compatibility
Tables for Layout
Use tables instead of divs for layout structure
Alt Text
Include alt text for all images
Test Everywhere
Test emails across Gmail, Outlook, Apple Mail, etc.
Inline Images
Use Content ID (CID) for embedded images:Error Handling
Testing Emails
Local Development
For development, use a test service like Mailtrap:Test Email Function
Performance Considerations
Async Email Sending
Queue System (Advanced)
For high-volume applications, use a queue:Troubleshooting
Authentication failed (EAUTH)
Authentication failed (EAUTH)
- Use App Password, not regular Gmail password
- Enable 2-Factor Authentication first
- Check
GOOGLE_USERandGOOGLE_PWDin.env - Remove spaces from App Password
Connection timeout (ECONNECTION)
Connection timeout (ECONNECTION)
- Check internet connection
- Verify firewall allows SMTP (port 587)
- Try different Gmail SMTP port (465)
- Check if Gmail is blocking the connection
Emails go to spam
Emails go to spam
- Set up SPF, DKIM, and DMARC records
- Use a verified domain email
- Avoid spam trigger words
- Include unsubscribe link
- Authenticate with DKIM
Images not displaying
Images not displaying
- Use absolute URLs for images
- Or use CID attachments
- Include alt text
- Test in multiple email clients
Template rendering issues
Template rendering issues
- Use inline CSS only
- Use tables for layout
- Test in Litmus or Email on Acid
- Avoid modern CSS (flexbox, grid)
Next Steps
Reports
Generate Excel reports for email attachments
Configuration
Configure email environment variables
API Reference
See endpoints that trigger emails
Database
Store email logs in database