Sign inSign up

ariefsn/surat

By ariefsn

•Updated 5 months ago

Surat is a lightweight email notification service with support for MJML and Handlebars.

Image
Integration & delivery
Developer tools
1

533

ariefsn/surat repository overview

ā šŸ“§ Surat – Mini Email Notification Service

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.


⁠✨ Features

  • šŸ“© Send emails via any SMTP provider
  • šŸŽØ Templating with MJML + Handlebars
  • šŸ› ļø Auto-generated Swagger docs (/api)
  • 🐳 Docker image ready to use
  • šŸ”‘ Easy configuration via environment variables

ā šŸš€ Quick Start

⁠Pull image
docker pull ariefsn/surat:latest
⁠Run container
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
⁠Docker Compose
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"

ā āš™ļø Environment Variables

VariableRequiredDefaultDescription
PORTāœ…3000Port the app listens on
SMTP_HOSTāœ…ā€“SMTP server host
SMTP_PORTāœ…ā€“SMTP server port
SMTP_USERāœ…ā€“SMTP username
SMTP_PASSWORDāœ…ā€“SMTP password
SMTP_SECUREāŒfalseEnable TLS/SSL (true / false)
SMTP_POOLāŒtrueEnable connection pooling (true / false)
SMTP_MAX_CONNECTIONSāŒ10Max SMTP connections per pool
SMTP_MAX_MESSAGESāŒ100Max 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

ā šŸ“– API Documentation

Swagger UI is available at:
šŸ‘‰ http://localhost:3000/api

Endpoints:

  • GET / → Health check
  • POST /email → Send an email
  • POST /mjml → Convert MJML to HTML

⁠🧩 Handlebars Helpers

The service provides several custom Handlebars helpers out of the box, so you can use them directly inside your email templates:

HelperExample (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>

ā šŸ›  Tech Stack


ā šŸ“œ License

This project is licensed under the MIT License⁠.

Tag summary

Content type

Image

Digest

sha256:3d3bf9bae…

Size

65.5 MB

Last updated

5 months ago

docker pull ariefsn/surat