The Email Service handles outgoing email communication. It provides a unified API for sending transactional emails (like welcome messages, password resets) using SMTP providers and manages HTML email templates.
- Email Sending: Relaying emails via SMTP (e.g., Gmail, SendGrid).
- Template Management: Storing and retrieving HTML email templates.
- Logging: Tracking sent emails (basic logging).
- Language: Go
- Framework: Fiber
- Database: SQLite (
email_db - configurable via EMAIL_DB_NAME)
- ORM: GORM (implied by repository usage)
- SMTP: Native Go SMTP
All endpoints are internal and prefixed with /internal/email. They require X-Internal-Token.
| Method |
Endpoint |
Description |
Payloads |
POST |
/send |
Send email using template |
{template_name, recipient, data} |
POST |
/send-raw |
Send raw HTML/Text email |
{to, subject, body} |
| Method |
Endpoint |
Description |
POST |
/templates |
Create new template |
GET |
/templates |
List all templates |
GET |
/templates/:name |
Get specific template |
| Method |
Endpoint |
Description |
GET |
/logs |
Get email logs |
| Variable |
Description |
Required |
Default |
PORT |
Service port |
No |
5005 (implied) |
EMAIL_DB_NAME |
SQLite DB name |
No |
email_db |
SMTP_HOST |
SMTP Server Host |
Yes |
localhost |
SMTP_PORT |
SMTP Server Port |
Yes |
587 |
SMTP_USERNAME |
SMTP Username |
Yes |
- |
SMTP_PASSWORD |
SMTP Password |
Yes |
- |
SMTP_FROM |
Default From Address |
Yes |
no-reply@example.com |
go run services/go/email/cmd/main.go