Skip to content

Feature Request: Support Cloudflare Email Service (REST API) as a sending relay via SMTP-to-REST gatewayย #7199

@ZHconsultores

Description

@ZHconsultores

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):

  1. An official smtp2cf companion container published alongside Mailcow
  2. A documented docker-compose.override.yml example in the Mailcow docs
  3. A community-maintained repository linked from the official docs

Happy to contribute a proof-of-concept implementation if there is interest from maintainers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions