Summary
Cloudflare recently launched their Email Service (Beta), which provides a REST API and Workers binding for sending transactional emails. Unlike traditional ESPs, it does not expose an SMTP endpoint โ making it incompatible with Postfix's native relayhost mechanism out of the box.
This feature request proposes either official support or documented guidance for integrating Cloudflare Email Service into Mailcow through a lightweight SMTP-to-REST gateway, deployable as a companion Docker container.
Motivation
Many Mailcow users already rely on Cloudflare for DNS, CDN, and tunneling. Cloudflare Email Service extends this ecosystem with a managed transactional sending infrastructure that automatically provisions SPF, DKIM, and DMARC records โ significantly lowering the operational overhead of outbound email deliverability.
Current alternatives (SendGrid, Mailgun, Brevo, etc.) all provide SMTP relay endpoints and integrate with Mailcow trivially. Cloudflare does not, leaving users who prefer to stay within the Cloudflare ecosystem without a clean integration path.
The proposed approach bridges this gap without modifying Mailcow core:
Mailcow (Postfix)
โ SMTP relay โ localhost:2525
[smtp2cf gateway] โ Docker sidecar
โ POST https://api.cloudflare.com/client/v4/accounts/<ID>/email/sending/send
The gateway:
- Runs as a standalone Docker container on the same network as Mailcow
- Listens on a local SMTP port (e.g.
2525)
- Accepts messages from Postfix via standard
relayhost or transport_maps config
- Parses the MIME message and translates it to a Cloudflare REST API call with Bearer token auth
- Handles multiple
RCPT TO recipients by looping individual API calls
- Returns standard SMTP response codes back to Postfix
Postfix integration is minimal:
# data/conf/postfix/extra.cf
relayhost = [smtp2cf]:2525
smtp_tls_security_level = none
Or scoped to specific domains via transport_maps for selective routing, leaving regular mail unaffected.
Additional context
- Cloudflare Email Service docs: https://developers.cloudflare.com/email-service/get-started/send-emails/
- REST API reference: https://developers.cloudflare.com/email-service/api/send-emails/rest-api/
- The service is currently in Beta โ API surface may change, but the core send endpoint is stable enough to build against.
- This integration is only applicable to domains with DNS managed by Cloudflare, which is already a common setup among Mailcow users running behind Cloudflare.
- The gateway could be implemented in Python (
aiosmtpd + httpx) in under 150 lines, making it a realistic candidate for an official companion container or a documented community add-on.
- No changes to Mailcow's core codebase would be required โ this could live as a separate repository under the mailcow organization or as a documented
docker-compose.override.yml example.
Proposed deliverables (any of the following would be valuable):
- An official
smtp2cf companion container published alongside Mailcow
- A documented
docker-compose.override.yml example in the Mailcow docs
- A community-maintained repository linked from the official docs
Happy to contribute a proof-of-concept implementation if there is interest from maintainers.
Summary
Cloudflare recently launched their Email Service (Beta), which provides a REST API and Workers binding for sending transactional emails. Unlike traditional ESPs, it does not expose an SMTP endpoint โ making it incompatible with Postfix's native
relayhostmechanism out of the box.This feature request proposes either official support or documented guidance for integrating Cloudflare Email Service into Mailcow through a lightweight SMTP-to-REST gateway, deployable as a companion Docker container.
Motivation
Many Mailcow users already rely on Cloudflare for DNS, CDN, and tunneling. Cloudflare Email Service extends this ecosystem with a managed transactional sending infrastructure that automatically provisions SPF, DKIM, and DMARC records โ significantly lowering the operational overhead of outbound email deliverability.
Current alternatives (SendGrid, Mailgun, Brevo, etc.) all provide SMTP relay endpoints and integrate with Mailcow trivially. Cloudflare does not, leaving users who prefer to stay within the Cloudflare ecosystem without a clean integration path.
The proposed approach bridges this gap without modifying Mailcow core:
The gateway:
2525)relayhostortransport_mapsconfigRCPT TOrecipients by looping individual API callsPostfix integration is minimal:
Or scoped to specific domains via
transport_mapsfor selective routing, leaving regular mail unaffected.Additional context
aiosmtpd+httpx) in under 150 lines, making it a realistic candidate for an official companion container or a documented community add-on.docker-compose.override.ymlexample.Proposed deliverables (any of the following would be valuable):
smtp2cfcompanion container published alongside Mailcowdocker-compose.override.ymlexample in the Mailcow docsHappy to contribute a proof-of-concept implementation if there is interest from maintainers.