MiniSMTP: a Self-Hosted SMTP Relay with an HTTP API in Docker
· SMTP · Docker · HTTP API ·
Transactional emails are needed by almost every backend project, but an external email service is not always suitable. MiniSMTP closes a narrow task: deploys its own SMTP-relay on VPS and gives the application a simple HTTP interface for sending emails.
In short: MiniSMTP — is not a marketing platform or an attempt to re-write an email server. This is a compact layer between the application and the verified mail stack: a clear HTTP contract on the outside, SMTP and delivery settings on the inside.
What problem does MiniSMTP solve?
Confirmation of registration, password recovery, invoice, check or system notification is usually sent through SendGrid, Mailgun, Postmark, Amazon SES and similar services. For a large product, this is a convenient path, but small and closed systems have additional limitations.
Price and dependency
The free limit ends, the cost changes along with the volume, and the code and operating processes begin to depend on the rules of the particular provider.
Outward transmission
Recipient addresses and email contents pass through third-party infrastructure. For domestic, legal, medical and financial systems, this may not be acceptable.
Excess complexity
Marketing analytics, visual editors, and campaign management are not needed if the project sends only a few types of service emails.
Complicated self-hosting
Own Postfix — is not just a package installation. You need DKIM, SPF, DMARC, PTR, TLS, access control and diagnosis of getting into spam.
MiniSMTP takes place between these options: retains control of the self-hosted solution, but hides the routine SMTP integration behind a small API.
What's inside.
The foundation serves docker-mailserver — finished stack Postfix, Dovecot and DKIM. MiniSMTP adds the Docker Compose configuration, HTTP API with Bearer token and a practical publication scenario via Nginx and Let's Encrypt.
-
Backend forms a letter
The application transmits the recipient, theme and text in a normal JSON request.
-
Nginx receives HTTPS
Reverse proxy terminates TLS and forwards the request to local API.
-
API checks the token
Request without correctness
Authorization: BearerIt doesn't get in the mail circuit. -
SMTP-relay sends a letter
Postfix delivers a message using domain settings and a DKIM signature.
For the calling application, the entire route looks like one stable HTTP contract. It doesn’t need a SDK email provider and doesn’t have to store SMTP logic in every project.
Sending a letter in one request
curl -X POST https://mail.example.com/send \
-H "Authorization: Bearer API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"to": "client@example.net",
"subject": "Registration confirmation",
"text": "Thank you! Your account has been created."
}'
Such an interface is equally easy to call from Laravel, Symfony, Node.js, Python, Go or a small shell script. When changing the language of the application, the postal infrastructure remains the same.
Deploying — is only half the task.
A working container does not mean that the emails will be sent to «. Therefore, the MiniSMTP documentation covers more than docker compose upbut also basic delivery.
DNS and signature
You need to generate a DKIM key, publish SPF and DMARC, and check PTR/rDNS for the IP server address.
Gradual incorporation of DMARC
Politics is wise to translate from observation p=none stricter quarantine After checking the actual traffic.
HTTPS and closed API
API is listening. 127.0.0.1. Only Nginx with TLS certificate Let's Encrypt is released to the external Internet.
Verification of the result
After setting up the domain, delivery is checked by test letter, message headers and service mail-tester.com.
The main difficulty of SMTP — is not to send a letter, but to prove to the receiving servers that the sender can be trusted.
Secure publication scheme
HTTP API should not be accessed directly from the Internet, otherwise the token and endpoint become the only barrier to abuse. The basic scheme leaves the service on the loopback interface and publishes only reverse proxy.
Internet
│ HTTPS :443
▼
Nginx + Let's Encrypt
│ localhost
▼
MiniSMTP API : internal port
│ SMTP
▼
docker-mailserver → recipient server
- A long random API token is stored in application secrets, not in a repository.
- Only the necessary ports are opened.
- Logs and query limits are controlled at the Nginx and application level.
- Access to VPS, DNS and backups is considered as part of email security.
Who is suitable for this relay?
Smaller SaaS and internal services
When emails are few, templates are limited and a separate marketing platform is not needed.
Projects with privacy requirements
When addresses and contents of messages must remain in a controlled infrastructure.
Agencies and developers
When multiple applications need a single way to send without different SDK accounts and rates.
Those who use the postal service
The repository links the settings of DKIM, SPF, DMARC, PTR and TLS to a working container environment.
Where is the decision boundary
MiniSMTP is designed for transactional mail of moderate volume. It does not replace the full-fledged ESP if the business needs mass mailings, visual editor, segmentation, campaign stats, and automatic reputation management.
| The challenge | MiniSMTP | External ESP |
|---|---|---|
| Service Letters from a Small Project | Suitable. | Suitable, but may be excessive. |
| Control of infrastructure and data | On your side. | Depends on the provider. |
| Marketing campaigns | Not intended. | Suitable. |
| Bounce, complaint and unsubscribe | Need to be implemented separately | Usually built-in. |
| A sharp increase in volume | Requires manual control | It's easier to scale |
In the minimum version, there is no queue with repeated attempts, automatic processing of bounce/complaint and unsubscribe compliance for marketing messages. If these features are required, add them around relay or choose a dedicated provider.
What happened in the end?
MiniSMTP converts a complex but typical infrastructure problem into a reproducible configuration. The app sends JSON over HTTPS, API checks the token, and the email stack is responsible for SMTP and DKIM. The team retains control over the server, domain and data.
The point of the decision is not to abandon external services at any cost. It is useful where volume is small, requirements are clear, and control and predictability are more important than the built-in marketing ecosystem.
Need integration without depending on unnecessary services?
I design API integrations and internal services for a real process: with authorization, queues, journaling, secure publication and a clear operating scenario.
MiniSMTP · Docker · Postfix · Dovecot · DKIM · SPF · DMARC · Nginx · Let's Encrypt · HTTP API
