A containerised Postfix SMTP relay that delivers mail to Office 365 through the Microsoft Graph API.
559
A containerised Postfix SMTP relay that lets legacy systems and appliances — anything that only speaks plain SMTP — send notifications and alerts through Microsoft 365 / Office 365.
Mail is delivered via the Microsoft Graph API (sendMail), authenticated with Entra ID using the OAuth2 client-credentials flow (client secret or certificate). There is no SMTP AUTH to Microsoft and no dependency on Basic Authentication.
Access is limited to an explicit list of sender mailboxes, enforced both at the SMTP layer and by RBAC for Applications in Exchange Online. It is not a tenant-wide open relay.
linux/amd64 and linux/arm64.latest — most recent release1, 1.2, 1.2.3 — semantic-version tags (major / minor / exact)Architectures: linux/amd64, linux/arm64
Docker Compose:
services:
smtp-to-office365:
image: qctechnl/smtp-to-office365:latest
container_name: smtp-to-office365
restart: unless-stopped
ports:
- "25:25"
- "587:587"
environment:
RELAY_HOSTNAME: mail.example.com
RELAY_ALLOWED_NETWORKS: 10.0.0.0/8
RELAY_FROM_ADDRESSES: [email protected]
ENTRA_TENANT_ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ENTRA_CLIENT_ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ENTRA_AUTH_TYPE: secret
ENTRA_CLIENT_SECRET: your-client-secret-here
volumes:
- ./certs:/certs:ro
- ./sasldb:/var/lib/sasl2
- postfix-queue:/var/spool/postfix
volumes:
postfix-queue:
docker compose up -d
Plain docker run:
docker run -d --name smtp-to-office365 --restart unless-stopped \
-p 25:25 -p 587:587 \
-e RELAY_HOSTNAME=mail.example.com \
-e RELAY_ALLOWED_NETWORKS=10.0.0.0/8 \
-e [email protected] \
-e ENTRA_TENANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \
-e ENTRA_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \
-e ENTRA_AUTH_TYPE=secret \
-e ENTRA_CLIENT_SECRET=your-client-secret-here \
qctechnl/smtp-to-office365:latest
Before the first send you need an Entra ID app registration and a scoped Graph permission granted via RBAC for Applications in Exchange Online. The full setup guide is on GitHub.
| Variable | Required | Default | Description |
|---|---|---|---|
RELAY_HOSTNAME | yes | — | Hostname used in SMTP EHLO/HELO |
RELAY_ALLOWED_NETWORKS | yes | — | Networks allowed to relay without auth (space-separated CIDR) |
RELAY_FROM_ADDRESSES | yes | — | Space-separated mailbox addresses allowed to send |
ENTRA_TENANT_ID | yes | — | Entra ID tenant ID |
ENTRA_CLIENT_ID | yes | — | App registration client ID |
ENTRA_AUTH_TYPE | yes | — | secret or certificate |
ENTRA_CLIENT_SECRET | if secret | — | Client secret value |
SMTP_TLS_LEVEL / SUBMISSION_TLS_LEVEL | no | may | Inbound TLS: none, may, encrypt |
GRAPH_LARGE_ATTACHMENTS | no | true | Support attachments > 3 MB |
LOG_LEVEL | no | info | error, info, debug, verbose |
The full variable reference, certificate authentication, TLS setup and RBAC configuration are documented on GitHub.
Full setup guide, Entra ID / RBAC configuration and troubleshooting: github.com/qctechnl/SMTP-to-Office365
Dutch documentation is available in the repository (README.nl.md).
MIT — QC Tech (https://qctech.nl), built by Mark Bartelen.
Content type
Image
Digest
sha256:f9620a64e…
Size
76.8 MB
Last updated
7 days ago
docker pull qctechnl/smtp-to-office365:dev