Drop-in SMTP Relay: A Simple Script to Tame Bot-Driven Email Floods

Article illustration 1

Public-facing web forms—signup pages, contact forms, password resets—are prime targets for abusive scripts. Bots hammer these endpoints, triggering a deluge of identical emails that overwhelm recipients' inboxes. Traditional defenses like CAPTCHA or form-level blocking often fall short, leaving developers scrambling for deeper protection at the email delivery layer.

A team at Qbix has addressed this pain point with a minimalist SMTP relay: a single JavaScript script that sits between applications and the real SMTP server. Detailed in a community post, the relay implements "defense in depth" by processing every outgoing email without altering existing codebases.

How the Relay Works

The script performs three core functions to curb abuse:

  1. Instant First Delivery: Legitimate single submissions pass through immediately, preserving user experience.

  2. Batching and Digests: Multiple emails to the same recipient within a short window are consolidated into one digest. Instead of dozens of repetitive alerts, users receive a single summary:

    "Instead of: [Subject] x100
    The recipient gets: [Digest with count and details]"

  3. Adaptive Backoff: Persistent spam triggers escalating delays between digests, turning floods into trickles. Configurable intervals reset automatically when activity normalizes, ensuring no bleed-over to future legitimate messages.

Additionally, it enforces strict attachment policies: oversized or excess files are summarized rather than delivered, neutralizing common bot tactics.

// Example integration - no app changes needed
// Before: smtp://real-server:25
// After:  smtp://relay-server:25

Universal Compatibility and Deployment

Designed for agnosticism, the relay requires zero SDKs, plugins, or framework dependencies. Apps in PHP, Node.js, Python, Ruby, or Go simply repoint their SMTP configuration to the relay's address. It forwards processed messages to the backend SMTP server.

"No code changes required. We do that too—but we want guarantees. Applications have bugs. Developers forget edge cases."

This makes it a robust last line of defense against edge cases like buggy monitoring scripts, 3 AM loops, or novel spammer techniques that bypass higher-layer protections.

The open-source script is available at GitHub. Developers can drop it into any stack for immediate relief from redundant email storms.

Implications for Web Developers

In an era where bot traffic constitutes over 50% of Internet activity, this relay fills a critical gap. Unlike heavy-weight solutions requiring app refactors, its drop-in nature empowers rapid deployment across microservices, monoliths, or hybrid environments. For DevOps teams managing high-traffic sites, it reduces operational toil—fewer alerts, quieter inboxes, quieter on-call rotations.

As bots evolve, tools like this underscore the need for layered defenses: form validation + rate limiting + SMTP hardening. Qbix's contribution democratizes this protection, offering a free, battle-tested script that scales with real-world abuse patterns.