This is a simple api server written in Rust that transfers emails sent via an HTTP request to a postfix instance.
Securing postfix is hard but having it inside a docker network alongside this relay is secure. This also lets you have a simple REST API to call rather than using SMTP libraries.
- WEBHOOK_SECRET: Secret to be used in the webhook
docker run
-d
-e SMTP_SERVER="postfix"
-e WEBHOOK_SECRET="Bearer xyz"
merlleu/email-relay-api:latest
POST /v1/emails
Authorization: Bearer {WEBHOOK_SECRET}
Content-Type: application/json
[
{
"from": {"name": "merlleu", "email": "[email protected]"},
"to": {"name": "some1", "email": "[email protected]"},
"reply_to": {"name": "merlleu", "email": "[email protected]"},
"subject": "Hello",
"text_body": "Hello, this is a test email",
"html_body": "<h1>Hello</h1><p>this is a test email</p>"
},
{
"from": {"name": "merlleu", "email": "[email protected]"},
"to": {"name": "some2", "email": "[email protected]"},
"reply_to": {"name": "merlleu", "email": "[email protected]"},
"subject": "Hello",
"text_body": "Hello, this is a test email #2",
"html_body": "<h1>Hello</h1><p>this is a test email #2</p>"
}
]
Response:
[
{"Ok": {}},
{"Err": "error message"}
]