notifr is a simple HTTP server that resends incoming messages to configured delivery services.
The application allows you to aggregate messages from different services and sends them to recipients. The server receives an HTTP request that contains a message and target. You can specify several recipients for each target and delivery methods in the notifr's configuration. It is possible to use Markdown format messages in the requests, which are converted to HTML when sending emails. notifr supports resending the email in the event of a failed attempt to send with a temporary net error (ECONNRESET and ECONNABORTED).
The main goal of this application is a simplification of other services that need to broadcast notifications.
- Messages in CommonMarkdown format with extensions that is provided provided by blackfriday library;
- Support SMTP delivery.
- SMTP Relay server (e.g. postfix).
docker pull icoreru/notifr
go install ./...
The application is configured via environment variables.
Names of the environment variables start with prefix NOTIFR_
.
See a list of the environment variables using the command:
notifr -h
Configuration of notification targets is comma-separated values with colons as row separators. Each target value has the next format TargetName:DeliveryName:Recipient
.
To notify you should send HTTP request:
curl -X POST -H 'Content-Type: application/json' -d 'REQUEST_BODY' http://localhost:8080/notifr?target=TARGET_NAME
A request body must follow to the next JSON scheme:
type: object
properties:
subject:
type: string
text:
type: string
required:
- text
Property text
contains a message text in Markdown format (standard markdown syntax).
If the property subject
not defined the first line from the text
field is truncated to 78 characters and adding in the subject while sending an email.
Start the server:
docker run --name notifr -p 8080:8080 \
-e NOTIFR_SMTP_HOST=smtp.example.org \
-e NOTIFR_TARGETS=test:smtp:[email protected] \
icoreru/notifr
Send a notification:
curl -X POST -H 'Content-Type: application/json' -d '{"subject":"My first notification","text":"## A list\n- First\n- Second\n- Third"}' http://localhost:8080/notifr?target=test
Email:
Subject: My first notification
Content-Type: text/html; charset=UTF-8
<h2>A list</h2>
<ul>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ul>
curl -X POST -H 'Content-Type: application/json' -d '{"text":"# My first notification\n## A list\n\n- First\n- Second\n- Third"}' http://localhost:8080/notifr?target=test
Email:
Subject: My first notification
Content-Type: text/html; charset=UTF-8
<h1>My first notification</h1>
<h2>A list</h2>
<ul>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ul>
Thanks for your interest in contributing to this project. Get started with our Contributing Guide.
The code in this project is licensed under MIT license.