Download Game! Currently 72 players. Last logged in:MalcomRobinhoodMeiggAxl

Blitzer's Blog >> 73041

Back to blogs index
Posted: 15 Oct 2026 18:14 [ permalink ]
Your intuition is exactly right, and it is by far the most elegant,
zero-maintenance approach. Running a local SMTP server involves endless
battles with spam filters, TLS certificates, and open ports.
By leveraging the existing Cloudflare ecosystem and your mesh domains, we can
build a serverless email bridge that requires zero polling and integrates
instantly with the REST API.
Here is the most straightforward, optimal architecture: Cloudflare Email
Routing  Cloudflare Worker  HAUKI REST API.
The Serverless Email Bridge Architecture
1. The Catch-All Address (Cloudflare Email Routing)
You configure Cloudflare Email Routing on one of your active mesh domains. You
set up a rule that routes any email sent to a specific address (e.g.,
genesis@omega-mesh.org or roundtable@omega-mesh.org) directly to a Cloudflare
Worker.
2. The Inbound Parse Worker
Cloudflare Workers support a native email event handler. When an email
arrives, the Worker intercepts it before it ever hits a real inbox. The
Worker's job is to:
 * Extract the sender's email address (From).
 * Parse the raw MIME stream to extract the plain text body.
 * Strip out quoted replies and email signatures to isolate the new
contribution.
3. Direct REST Injection (Bypassing KV)
While the Worker could drop the message into a KV bucket, it doesn't need to.
Because you already have a cloudflared tunnel exposing the REST API to the
edge, the Worker can simply fire a standard HTTP POST directly to
[https://api.your-mesh-domain.com/api/objects/0/mail](https://api.your-mesh-dom
ain.com/api/objects/0/mail).
The request travels through the secure tunnel, hits your Node.js router, gets
translated into tagged pointers, and wakes the chair_daemon.c instantly.
The Cloudflare Worker Blueprint
Here is what the Worker script looks like. It uses a lightweight parsing
library (like postal-mime) to handle the messy reality of multipart email
formats.
import PostalMime from 'postal-mime';

export default {
  async email(message, env, ctx) {
    // 1. Parse the raw incoming email stream
    const parser = new PostalMime();
    const parsedEmail = await parser.parse(message.raw);
    
    // 2. Extract the sender and the plain text body
    const sender = parsedEmail.from.address;
    let textBody = parsedEmail.text || "";

    // 3. Strip quoted replies (standard ">" email formatting)
    textBody = textBody.split(/\r?
(?=>|On.*wrote:|From:)/)[0].trim();

    // 4. Construct the JSON payload for HAUKI
    const payload = [sender, textBody];

    // 5. Fire it through the Cloudflare Tunnel to the Engine
    const engineUrl = "https://api.your-mesh-domain.com/api/objects/0/mail";
    
    try {
      const response = await fetch(engineUrl, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(payload)
      });
      
      if (!response.ok) {
        console.error("HAUKI Engine rejected payload:", await
response.text());
      }
    } catch (error) {
      console.error("Failed to route email to HAUKI:", error);
    }
  }
};

Why this is optimal:
 * True Push, Zero Poll: The VM stays asleep at 0% CPU until the exact
millisecond an email arrives.
 * Security: You don't have to open port 25 on your local server. The tunnel
handles all ingress securely.
 * Cost: Cloudflare Email Routing and the first 100,000 Worker requests per
day are entirely free.
Would you like to draft this Worker in your project repository so we can
deploy it, or would you prefer to set up the DNS MX records in the Cloudflare
dashboard first?