Overview
BookMe sends email notifications to users when they create reservations. The email service uses SMTP with TLS encryption and supports multiple providers.Email notifications are sent for all successful reservations, confirming the room, date, and time details.
Email Template
BookMe uses HTML email templates located atinternal/email/templates/confirmation_email_v2.html. The confirmation email includes:
- Room name
- Reservation date and time
- Start and end times
- Hive Helsinki branding
SMTP Configuration
Add SMTP credentials to your.env file:
Configuration Variables
| Variable | Required | Default | Description |
|---|---|---|---|
SMTP_HOST | Yes | - | SMTP server hostname |
SMTP_PORT | No | 587 | SMTP server port (587 for TLS, 465 for SSL) |
SMTP_USERNAME | Yes | - | SMTP authentication username |
SMTP_PASSWORD | Yes | - | SMTP authentication password |
FROM_EMAIL | Yes | - | Email address used as sender |
FROM_NAME | No | BookMe | Display name for the sender |
SMTP_USE_TLS | No | true | Enable STARTTLS encryption |
Provider-Specific Setup
Gmail
Gmail requires an App Password when using SMTP with 2-factor authentication.Enable 2-Factor Authentication
Go to Google Account Security and enable 2-Step Verification.
Generate App Password
- Visit App Passwords
- Select Mail as the app
- Select Other as the device and enter “BookMe”
- Click Generate
- Copy the 16-character password (remove spaces)
Configure Environment
You can use your Gmail address as
FROM_EMAIL, or use a custom address like [email protected] (Gmail will still send from your account).SendGrid
SendGrid is a popular transactional email service with a free tier.Create SendGrid Account
Sign up at SendGrid and verify your account.
Create API Key
- Go to Settings → API Keys
- Click Create API Key
- Name it “BookMe SMTP”
- Select Full Access or Mail Send permission
- Copy the API key
Mailgun
Mailgun offers powerful email APIs with SMTP support.Create Mailgun Account
Sign up at Mailgun and verify your account.
Get SMTP Credentials
- Go to Sending → Domain Settings
- Select your domain (use sandbox domain for testing)
- Find SMTP Credentials section
- Create a new SMTP user or use the default
AWS SES (Amazon Simple Email Service)
AWS SES is cost-effective for high-volume email sending.Set Up SES
- Log into AWS Console
- Navigate to SES service
- Verify your email address or domain
- Request production access (if out of sandbox)
Create SMTP Credentials
- Go to SMTP Settings
- Click Create SMTP Credentials
- Download the credentials CSV
Office 365 / Outlook
For organizations using Microsoft 365.Email Service Features
The BookMe email service (implemented ininternal/email/email_service.go) includes:
Retry Logic
Automatic retry with exponential backoff:- Attempts: 3 retries
- Initial delay: 4 seconds
- Maximum delay: 10 seconds
TLS Encryption
All emails are sent over encrypted connections using STARTTLS.HTML Templates
Professional HTML email templates with embedded CSS for consistent rendering across email clients.Testing Email Configuration
Test SMTP Connection
Create a simple test:Manual SMTP Test
Test SMTP connectivity usingtelnet or openssl:
Troubleshooting
Authentication Failed
- Verify
SMTP_USERNAMEandSMTP_PASSWORDare correct - For Gmail: ensure you’re using an App Password, not your regular password
- Check if 2FA is enabled and requires app-specific password
Connection Timeout
- Check
SMTP_HOSTis correct - Verify
SMTP_PORT(usually 587 for TLS, 465 for SSL) - Ensure firewall allows outbound connections on the SMTP port
- Try alternative port (587, 465, or 25)
TLS Handshake Failed
- Set
SMTP_USE_TLS=true - Ensure using port 587 for STARTTLS
- Try port 465 for implicit SSL
Email Not Received
Check:- Spam folder: Emails may be filtered as spam
- Sender verification: Some providers require verified sender addresses
- Logs: Check application logs for sending errors
- Rate limits: You may be hitting provider rate limits
Template Rendering Failed
- Verify email templates exist in
internal/email/templates/ - Check template syntax is valid HTML
- Ensure template data fields match
BookingDatastructure
Production Recommendations
Best Practices
- Use Dedicated Service: SendGrid, Mailgun, or AWS SES for reliability
- Monitor Send Rates: Track email delivery and bounce rates
- Implement SPF/DKIM: Set up email authentication records
- Handle Bounces: Monitor bounced emails and invalid addresses
- Rate Limiting: Respect provider rate limits
- Logging: Log all email sending attempts for debugging
Rate Limits
| Provider | Free Tier Limit | Notes |
|---|---|---|
| Gmail | ~500/day | For personal accounts |
| SendGrid | 100/day | Free tier |
| Mailgun | 5,000/month | First 3 months |
| AWS SES | 62,000/month | If sending from EC2 |
Email Template Customization
To customize the email template:Edit HTML
Modify the HTML template. Available variables:
{{.RoomName}}- Meeting room name{{.StartTime}}- Reservation start time{{.EndTime}}- Reservation end time
Templates are embedded into the binary at build time using Go’s
embed package (see internal/email/email_service.go:17).