Overview
The Restaurant Reservation System uses a comprehensive email notification system to keep both customers and business owners informed about reservation activities. All notifications are sent automatically using Firebase’s Trigger Email Extension.Email Service Architecture
Implementation
TheServicioEmail class handles all email operations:
source/lib/adaptadores/servicio_email.dart
Firebase Integration
Emails are sent through Firebase Firestore triggers:source/lib/adaptadores/servicio_email.dart:368-398
The Firebase Trigger Email Extension must be installed and configured for emails to be delivered. See the Email Configuration Guide.
Customer Notifications
Customers receive automated emails for all reservation activities.Reservation Confirmed
Sent when a customer successfully creates a reservation:- ✅ Confirmation badge with green styling
- 📋 Complete reservation details table
- 💡 Important reminders:
- Arrive 10 minutes early
- Cancellation policy (2 hours advance notice)
- Save email for reference
- 📧 Restaurant contact information
source/lib/adaptadores/servicio_email.dart:18-72
Customer Cancellation Confirmation
Sent when a customer cancels their own reservation:- ❌ Cancellation confirmation with red accent
- 📋 Cancelled reservation details
- 🔄 Invitation to book again
source/lib/adaptadores/servicio_email.dart:75-116
Restaurant Cancellation Notice
Sent when the restaurant cancels a customer’s reservation:- ⚠️ Cancellation notice with warning styling
- 📋 Original reservation details
- 📝 Reason for cancellation (if provided)
- 🙏 Apology for inconvenience
- 🔄 Invitation to rebook
source/lib/adaptadores/servicio_email.dart:119-175
Business Owner Notifications
Restaurant owners receive notifications for customer reservation activities.New Reservation Alert
Sent when a customer creates a new reservation:- 📋 “Nueva Reserva Recibida” header
- 👤 Customer contact information (email and phone)
- 📅 Complete reservation details
- 🏪 Restaurant name
source/lib/adaptadores/servicio_email.dart:182-222
Customer Cancellation Alert
Sent when a customer cancels their reservation:- ❌ “Un cliente ha cancelado su reserva” header
- 📋 Cancelled reservation details
- ℹ️ Note that table is now available
source/lib/adaptadores/servicio_email.dart:225-258
Business owners do NOT receive email notifications when they cancel reservations themselves, as they performed the action directly.
Email Templates
All emails use a consistent HTML template with responsive design.Template Structure
source/lib/adaptadores/servicio_email.dart:401-436
Color Scheme
| Color | Usage | Hex Code |
|---|---|---|
| Green | Confirmation, success | #27AE60 |
| Red | Cancellation | #F44336 |
| Orange | Warning, restaurant cancellation | #FF9800 |
| Gray | Neutral information | #666666 |
Reservation Details Table
All emails include a formatted details table:source/lib/adaptadores/servicio_email.dart:439-498
Date and Time Formatting
Dates and times are formatted in Spanish:Date Format
lunes 10 de marzo de 2026viernes 15 de marzo de 2026domingo 20 de diciembre de 2026
source/lib/adaptadores/servicio_email.dart:501-532
Time Format
12:00 hs19:30 hs21:45 hs
source/lib/adaptadores/servicio_email.dart:534-538
Using Email Service
With Reserva Entity
Convenience methods acceptReserva objects directly:
- Sends confirmation email to customer
- Sends new reservation alert to owner
source/lib/adaptadores/servicio_email.dart:265-300
Customer Cancellation
- Sends cancellation confirmation to customer
- Sends cancellation alert to owner
source/lib/adaptadores/servicio_email.dart:303-335
Restaurant Cancellation
source/lib/adaptadores/servicio_email.dart:338-359
Email Validation
The system validates email addresses before sending:Firestore Email Collection
Emails are stored in Firestore for tracking:Delivery States
| State | Description |
|---|---|
PENDING | Email queued for delivery |
PROCESSING | Currently being sent |
SUCCESS | Delivered successfully |
ERROR | Delivery failed |
You can monitor email delivery status in the Firebase Console under the
mail collection.Troubleshooting
Problem: Emails Not Being Sent
Possible causes:- Firebase Trigger Email Extension not installed
- SMTP credentials not configured
- Email quota exceeded
- Invalid recipient email address
Problem: Emails Going to Spam
Possible causes:- SMTP server reputation issues
- Missing SPF/DKIM records
- Generic “no-reply” sender address
- Configure SPF and DKIM records for your domain
- Use a recognizable sender address
- Include unsubscribe link (for marketing emails)
- Test with multiple email providers
Problem: Duplicate Emails
Possible causes:- Multiple calls to email service
- Retry logic triggering unnecessarily
- Add idempotency checks
- Verify email service is called only once per event
- Check for duplicate reservation confirmations
Best Practices
Test Before Production
Test Before Production
Always test emails before deploying:
- Send test emails to yourself
- Verify formatting on multiple devices
- Check spam folder
- Test all notification types
Monitor Delivery
Monitor Delivery
Regularly monitor email delivery:
- Check Firebase Console for errors
- Review
mailcollection delivery states - Track bounce rates
- Monitor SMTP quota usage
Maintain Email Quality
Maintain Email Quality
Keep emails professional and useful:
- Clear subject lines
- Complete information
- Professional tone
- Mobile-responsive design
Respect Privacy
Respect Privacy
Handle customer data responsibly:
- Only send relevant notifications
- Secure email content
- Don’t share customer emails
- Comply with privacy regulations
Email Configuration
For detailed instructions on setting up the Firebase Trigger Email Extension and SMTP configuration, see:Email Configuration Guide
Step-by-step guide to configure email delivery with Firebase
Next Steps
Reservation Management
Learn how reservation actions trigger email notifications
Business Configuration
Configure your restaurant settings