A lightweight REST API for sending styled HTML or plain text emails using Spring Boot, Thymeleaf, and Docker.
- ✅ Send plain text emails
- ✅ Send HTML emails with dynamic data (via Thymeleaf)
- ✅ Simple webhook endpoint for quick email triggers
- ✅ Dockerized for easy deployment
- 🔒 API key protection
- 🔧 Templating system via mounted
/templates
directory
The API uses Thymeleaf to render email templates. You can insert variables in your .html
templates, and supply their values through the data
field in your request.
Place your HTML template files in the /templates/
directory (mounted via Docker volume).
{
"to": "[email protected]",
"subject": "Test email!",
"template": "test.html",
"data": {
"name": "sivikee",
"link": "https://example.com"
}
}
🧠 The data
object will be used to populate template variables.
X-API-Key: your-api-key
Returns the rendered HTML of the provided template + data, without sending the email. Useful for debugging.
You can trigger simple emails using form parameters:
Parameters:
to
subject
body
📌 No templating here — just quick plain text emails.
Use environment variables (via .env
or Docker) to configure:
SPRING_MAIL_HOST=smtp.example.com
SPRING_MAIL_PORT=587
SPRING_MAIL_USERNAME=your_username
SPRING_MAIL_PASSWORD=your_password
SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH=true
SPRING_MAIL_PROPERTIES_MAIL_SMTP_SSL_ENABLE=false
SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE=true
API_KEY=your-api-key
API_TEMPLATE_DIR=/app/templates
docker-compose up --build
Mount your local templates/
folder into the container:
volumes:
- ./templates:/app/templates
- Send plain text emails
- Send HTML emails via templates
- Webhook support
- Dockerized build
- Add OpenAPI (Swagger) spec
- Improve README and usage examples ✅
- Add CI/CD pipeline
- Full documentation
- File attachments via multipart form
MIT – free to use, modify, and deploy.