Prompt

How do I rate limit email sends in my app?

Technology / API Platforms3 observationsLast seen Nov 13, 2026

Latest observation

Nov 13, 2026OpenAI APIWeb search: off

To rate-limit email sends, you typically want two layers of protection:

  1. Per-user / per-action limits to stop abuse from a single account or endpoint
  2. Global sending limits to stay within your email provider’s quotas and protect deliverability

Common approaches

1) Fixed window counters

Track how many emails were sent in a time window.

Example:

  • Max 5 verification emails per hour per user
  • Max 20 password reset emails per day per IP

Store counters in Redis or your database with an expiry.

Redis example idea

  • Key: email:sent:user123:verification:2026-11-13T10
  • Increment each send
  • Reject if count exceeds limit

Pros: simple
Cons: can allow bursts at window boundaries


2) Sliding window

Track sends over the last N minutes/hours more accurately.

Instead of counting per calendar hour, count emails sent in the last 60 minutes.

Pros: smoother and fairer
Cons: slightly more complex


3) Token bucket / leaky bucket

Give each user or system bucket of “send tokens.”

  • Emails consume tokens
  • Tokens refill over time

Example:

  • 10 tokens max
  • refill 1 token every 6 minutes
  • sending an email uses 1 token

Pros: good for burst handling
Cons: more logic to implement


What to rate limit

A good setup is to rate limit by:

  • User account
  • Email address
  • IP address
  • Action type
    (signup verification, password reset, invoice, marketing, etc.)

Examples:

  • Password reset: 3 per hour per email
  • Verification resend: 5 per day per account
  • Marketing batch sends: global per minute based on provider limits

Implementation tips

Use Redis if possible

Redis is ideal because it’s fast and supports atomic increments and expiration.

Pseudo-flow:

  1. Build a key from user/action/time bucket
  2. Increment the key atomically
  3. Set expiry if first time
  4. If count > limit, block send
  5. Otherwise send email

Make the send idempotent

If your app retries after a timeout, you don’t want duplicate sends. Use a unique request ID or dedupe key.

Queue emails

For production, put sends into a job queue:

  • app enqueues email job
  • worker checks rate limit
  • worker sends email
  • if over limit, job is delayed/requeued or discarded

This prevents spikes and keeps your app responsive.


Example policy

A practical default:

  • Per user: max 5 transactional emails / hour
  • Per email address: max 3 password reset emails / hour
  • Per IP: max 20 email-triggering requests / hour
  • Global: match your provider’s limits (e.g. 100/sec, depending on service)

Extra safeguards

  • Add CAPTCHA after repeated requests
  • Add cooldown timers in the UI (“Try again in 2 minutes”)
  • Log rate-limit rejections
  • Monitor delivery/bounce/complaint rates

If you want a quick Redis pattern

A simple fixed-window key:

key = "rate:email:verification:user123:2026-11-13T10"
INCR key
EXPIRE key 3600
if value > 5: reject

If you tell me your stack (Node, Python, Rails, Django, etc.) and whether you use Redis, I can show you a concrete implementation.

Brands

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (3 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.