Built a custom Postfix email server with no send-limit caps and a REST-accessible NLP parsing layer for AI-driven email context analysis and downstream automation.
Our client needed email infrastructure with two properties that commercial providers could not deliver together: no daily sending caps for high-volume transactional sending and programmatic access to incoming mail for AI processing - specifically, NLP-based analysis of email content to drive downstream automation workflows.
Standard SMTP relay services impose sending limits and do not expose incoming mail to custom processing pipelines. Building on a commercial email API would have meant accepting per-message pricing that made the economics unworkable at their expected volume.
Custom Postfix mail server
We configured a Postfix MTA on a Linux server for both outbound and inbound mail handling.
Outbound: Postfix relay queuing with per-domain delivery rate limits to manage reputation with receiving mail servers and SPF/DKIM/DMARC signing for deliverability.
Inbound: Postfix pipe transport routing incoming messages to a custom processing script before final delivery to mailboxes. The pipe transport invokes the processing script directly for each incoming message - achieving near-real-time delivery to the NLP layer without polling.
Domain and mailbox management is handled via MySQL virtual domain and mailbox tables. New domains and mailboxes are provisioned through the REST API without touching Postfix configuration files.
NLP parsing middleware (Python / SpaCy)
The processing script is a Python application that receives the raw MIME message from Postfix via stdin, extracts the relevant content fields - sender, subject, body, attachments - and passes them to the NLP analysis pipeline.
We used SpaCy for Named Entity Recognition, extracting people, organisations, dates and locations from message content. The extracted entities and their confidence scores are published to the downstream automation system via a REST webhook, giving the AI layer structured data rather than raw email content to work with.
REST API for infrastructure management
A REST API layer allows dynamic provisioning of domains and mailboxes without server access. Endpoints cover domain registration, mailbox creation and quota management, API key management for outbound sending and delivery logs and bounce tracking.
The Postfix pipe transport approach is more operationally coupled than alternatives like polling or IMAP IDLE, but it was the right tradeoff here. The client's AI workflows depended on low-latency delivery to the NLP layer - any polling interval would have introduced unnecessary lag between message receipt and downstream processing.
MySQL for virtual domains is the standard Postfix pattern and we followed it rather than introducing a different database. The REST API wraps the MySQL operations, so consuming applications do not need to know about the underlying data model.
The mail infrastructure handled the client's sending volume without the per-day caps that had constrained their previous setup. Incoming message processing latency - from server receipt to NLP entity extraction - averaged under two seconds in production. The REST provisioning API enabled the client's team to onboard new domains and mailboxes without server access, reducing operational dependency on infrastructure expertise.