Surat is a lightweight email notification service with support for MJML and Handlebars.
533
Surat is a lightweight email notification service with support for MJML (email templates), Handlebars (variable injection), and built-in Swagger API docs.
It is packaged as a Docker image for easy deployment with SMTP integration.
/api)docker pull ariefsn/surat:latest
docker run -d \
-p 3000:3000 \
-e PORT=3000 \
-e SMTP_HOST=smtp.example.com \
-e SMTP_PORT=587 \
-e SMTP_USER=myuser \
-e SMTP_PASSWORD=mypassword \
-e SMTP_SECURE=false \
-e [email protected] \
-e DEFAULT_SENDER_NAME="Surat" \
-e SMTP_POOL=true \
-e SMTP_MAX_CONNECTIONS=10 \
-e SMTP_MAX_MESSAGES=100 \
--name surat \
ariefsn/surat:latest
version: "3.8"
services:
surat:
image: ariefsn/surat:latest
container_name: surat
restart: unless-stopped
ports:
- "3000:3000"
environment:
PORT: 3000
SMTP_HOST: smtp.example.com
SMTP_PORT: 587
SMTP_USER: myuser
SMTP_PASSWORD: mypassword
SMTP_SECURE: "false"
SMTP_POOL: "true"
SMTP_MAX_CONNECTIONS: "10"
SMTP_MAX_MESSAGES: "100"
DEFAULT_SENDER_EMAIL: [email protected]
DEFAULT_SENDER_NAME: "Surat"
| Variable | Required | Default | Description |
|---|---|---|---|
PORT | ā | 3000 | Port the app listens on |
SMTP_HOST | ā | ā | SMTP server host |
SMTP_PORT | ā | ā | SMTP server port |
SMTP_USER | ā | ā | SMTP username |
SMTP_PASSWORD | ā | ā | SMTP password |
SMTP_SECURE | ā | false | Enable TLS/SSL (true / false) |
SMTP_POOL | ā | true | Enable connection pooling (true / false) |
SMTP_MAX_CONNECTIONS | ā | 10 | Max SMTP connections per pool |
SMTP_MAX_MESSAGES | ā | 100 | Max messages per connection |
DEFAULT_SENDER_EMAIL | ā | ā | Default sender email address |
DEFAULT_SENDER_NAME | ā | ā | Default sender display name |
š” You can store them in a .env file and run with:
docker compose --env-file .env up -d
Example .env:
PORT=3000
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=myuser
SMTP_PASSWORD=mypassword
SMTP_SECURE=false
[email protected]
DEFAULT_SENDER_NAME=Surat
Swagger UI is available at:
š http://localhost:3000/api
Endpoints:
GET / ā Health checkPOST /email ā Send an emailPOST /mjml ā Convert MJML to HTMLThe service provides several custom Handlebars helpers out of the box, so you can use them directly inside your email templates:
| Helper | Example (Template) | Result |
|---|---|---|
add | {{add 2 3}} | 5 |
gt | {{gt 5 3}} | true |
gte | {{gte 5 5}} | true |
lt | {{lt 2 5}} | true |
lte | {{lte 2 2}} | true |
eq | {{eq "a" "a"}} | true |
ne | {{ne "a" "b"}} | true |
or | {{or true false}} | true |
and | {{and true false}} | false |
not | {{not true}} | false |
contains | {{contains "hello world" "wor"}} | true |
startWith | {{startWith "hello" "he"}} | true |
endWith | {{endWith "hello" "lo"}} | true |
replace | {{replace "foo bar" "bar" "baz"}} | foo baz |
json | {{json myObject}} | {"key":"value"} |
š Example MJML + Handlebars usage:
<mj-text>
Hello {{name}},
You have {{add unreadCount 1}} unread messages.
</mj-text>
This project is licensed under the MIT Licenseā .
Content type
Image
Digest
sha256:3d3bf9baeā¦
Size
65.5 MB
Last updated
5 months ago
docker pull ariefsn/surat