Simple Mail is a prebuilt application for mail sending, supporting multiple templates and variables.
We designed it to be used primarily with Docker, but it can, with some light code modification be ran bare.
To run with Docker Compose:
services:
mailer:
image: murilofuza/simple-mail
env_file: .env
depends_on:
- redis
ports:
- '3002:3000'
volumes:
- /path/to/your/templates/folder:/templates
redis:
image: redis:alpine
volumes:
- redis:/dataBe sure that your .env file has the needed variables:
SMTP_HOST: Your mailing server hostSMTP_PORT: Your mailing server portSMTP_USER: Your mailing server usernameSMTP_PASS: Your mailing server passwordREDIS_HOST: Host of the redis instance to use. If using redis within the samedocker-compose.ymlcan be set toredisREDIS_PORT: Port that the redis instance is running on. The default port for redis instances is6379.REDIS_PASSWORD: Password for the redis instance. If none, can be left empty.DASHBOARD_USERNAME: Username to login to Bull dashboardDASHBOARD_PASSWORD: Password to login to Bull dashboard
You'll can provide the templates that the application can access and use. To do so, you can change the /path/to/your/templates/folder to a folder that contains you templates.
These templates must be handlebars templates, they'll be selected on request time.
After everything is up and running, you might want to send emails.
The API has only one endpoint: /send-email.
- Type:
POST - Endpoint:
/send-email - Body:
JSON
{
"from": "noreply@example.com", // Sender Email
"to": "john@example.com", // Recipient Email
"subject": "Test", // Email Subject
"html": "A big HTML string", // An HTML string can be used instead of a template and context.
"template": "main.hbs", // The template file selected. Relative to the template folder.
"context": { // Context can be
"name": "Jarvan Five" // Variable defined in handlebars template
// These are dynamic, if your template uses it, it must, or can be passed through here.
}
}There is a dashboard at /dashboard. The username and password should be the ones set at the .env