Skip to content

BjoernKW/MailTrigger

Repository files navigation

MailTrigger

License

MailTrigger is a service that allows you to asynchronously send emails using an HTTP API. Emails are represented as channels and generated from Markdown templates which are kept in the same source code repository as the software itself.

Hence, email templates can be managed using GitHub / GitLab (or the like) in-browser Markdown editors.

Alternatively, you can configure a custom template directory for loading email templates from the filesystem.

Getting Started

Prerequisites

Running the app in dev mode

Run mvn spring-boot:run from the command line.

Running the tests

Run mvn clean install from the command line.

Deployment

You can run the application by using the standard Spring Boot deployment mechanism (see these three articles for more information on Spring Boot deployment techniques and alternatives: Deploying Spring Boot Applications, Running your application , Installing Spring Boot applications):

java -jar target/mailtrigger-0.0.2-SNAPSHOT.jar

The application then should be available under http://localhost:8080

Via Docker

Alternatively, you can run the application in a Docker container (using the official MailTrigger Docker image):

docker run -p 8080:8080 bjoernkw/mailtrigger

In the project root folder, there's an example Dockerfile that can be used to build the image, as well as a sample docker-compose.yml with an example configuration. The latter can be used to run the application via the usual Docker Compose command:

docker-compose up

That sample docker-compose.yml configures a custom template directory.

Configuration

These environment variables are required for running MailTrigger:

  • SMTP_HOST
  • SMTP_PORT
  • SMTP_USERNAME
  • SMTP_PASSWORD

Sending an email

This HTTP call will load a template named test_channel.md and replace any placeholders with the replacements provided in the HTTP request body:

curl -d '{"TO": "test@test.com", "FIRST_NAME": "Jack"}' -H 'Content-Type: application/json' -X POST http://localhost:8080/api/v1/sendMail/test_channel

REST API Documentation

Once the app is started the REST API documentation will be available under http://localhost:8080/swagger-ui.html

Built With

License

Apache License 2.0

Authors