Email bounce classification isn't an afterthought — it's a core part of delivery architecture. Agents that send without handling bounces accumulate bad addresses, degrade sender reputation, and eventually lose the ability to deliver to anyone. The mechanics differ significantly from human-operated transactional email: agents often send at higher frequency, to programmatically assembled recipient lists, and without a human noticing a rising bounce rate.
This post covers what each bounce type actually means at the protocol level, how to parse DSN (Delivery Status Notification) messages, and what your agent's code should do with each category.
What a bounce actually is
A bounce is a failure notification returned by a receiving mail server. The failure can happen at two distinct moments:
- SMTP-time rejection: the receiving server refuses the message during the SMTP session, before the connection closes. Your sending server gets a 4xx or 5xx SMTP response code immediately.
- Post-acceptance DSN: the receiving server accepts the message (returns 250 OK), then later sends a Delivery Status Notification email back to the envelope sender address. This is common with relay chains and some spam filters.
The distinction matters for your pipeline. SMTP-time rejections are synchronous — your sending library or API gets the error code directly. DSNs arrive asynchronously, as inbound email, often minutes to hours later.
In practice, most modern sending APIs (and Mails.ai's webhook system) normalize both into a single bounced event with a status code and category, so you don't need to implement DSN parsing from scratch. Understanding the underlying mechanics still helps you interpret edge cases.
The three bounce categories
Bounce classification maps SMTP enhanced status codes (defined in RFC 3463) and reason strings into actionable categories.
Hard bounces: permanent failures
A hard bounce means the address does not exist or cannot receive mail permanently. The canonical SMTP indicator is a 5xx response, specifically the 5.1.x family:
5.1.1— The email account that you tried to reach does not exist5.1.2— Bad destination mailbox address5.1.3— Bad destination mailbox address syntax
When a hard bounce arrives, there is no retry strategy that makes sense. The address is invalid. Sending to it again wastes resources and signals to ISPs that your list hygiene is poor.
What your agent must do:
- Immediately add the address to a suppression list.
- Never send to it again, across any agent in your workspace.
- If the address was provided by a user (e.g., someone signed up with a typo), surface a notification so the upstream system can prompt them to correct it.
import { createClient } from "@mailsai/sdk";
const client = createClient();
// Webhook handler for bounce events
app.post("/webhooks/mail", async (req, res) => {
const event = mails.webhooks.verify(
req.rawBody,
req.headers["x-mails-signature"] as string,
process.env.WEBHOOK_SECRET!
);
if (!event) return res.sendStatus(401);
if (event.type === "message.bounced") {
const { address, bounce_type, smtp_code } = event.data;
if (bounce_type === "hard") {
await db.suppressions.upsert({
address,
reason: "hard_bounce",
smtp_code,
suppressed_at: new Date(),
});
// Notify upstream: this address is permanently invalid
await notifyUserOfBadAddress(address);
}
}
res.sendStatus(200);
});
One concrete benchmark: Google's Postmaster Tools documentation states that bounce rates above 2% trigger deliverability impacts for Gmail routing, and rates above 10% can result in bulk classification for all mail from that domain.
Soft bounces: temporary failures
Soft bounces use 4xx SMTP codes — the server is saying "not right now, try later." Common subcodes:
4.2.1— The user's mailbox is temporarily unavailable4.2.2— Mailbox full (over quota)4.4.1— Connection timeout4.4.2— Bad connection4.7.0— Rate limit exceeded (the receiving server is throttling you)
Soft bounces are ambiguous. Some resolve themselves — a full mailbox eventually gets emptied. Others are permanent in disguise: a decommissioned mailbox may respond with 4.2.1 for days before the domain admin changes it to 5.1.1.
Retry strategy for soft bounces: use exponential backoff with a maximum attempt ceiling. A reasonable policy:
| Attempt | Delay | Cumulative wait |
|---|---|---|
| 1 | immediate | 0 |
| 2 | 5 minutes | 5 min |
| 3 | 30 minutes | 35 min |
| 4 | 2 hours | ~2.5 hrs |
| 5 | 6 hours | ~8.5 hrs |
| 6 | 24 hours | ~32 hrs |
| Give up | suppress temporarily | 48 hrs |
After exhausting retries, treat the address as soft-suppressed (not permanently suppressed). Re-enable it after 30 days unless it bounces again.
For AI agents, the nuance is timing: an agent responding to an inbound request shouldn't be queuing retries in its own process. That belongs in your infrastructure layer — a job queue (BullMQ, Faktory, Celery) with idempotency keys, not inside the agent's reasoning loop.
Block bounces: policy rejections
Block bounces are a third category that many systems conflate with hard bounces. They are policy-based rejections — the address may be valid, but the receiving server is refusing delivery based on your sending infrastructure's reputation.
Common causes:
- Your IP or domain is listed on a blocklist (Spamhaus, SORBS, Barracuda)
- SPF alignment failure — your envelope sender doesn't match an authorized IP
- DKIM signature validation failure
- DMARC policy rejection (
p=rejectwith a failed alignment) - Content filters triggered by specific patterns in subject or body
Typical SMTP codes for blocks: 5.7.0, 5.7.1, 5.7.26 (DMARC failure), 5.7.28.
The critical difference: a block bounce does not mean the address is bad. If you suppress the address, you're solving the wrong problem. The issue is your sending infrastructure, not the recipient.
if (event.type === "message.bounced") {
const { address, bounce_type, bounce_subtype, smtp_code, diagnostic } = event.data;
switch (bounce_type) {
case "hard":
// Address is dead — suppress permanently
await suppressPermanently(address);
break;
case "soft":
// Schedule retry with backoff
await scheduleRetry(event.source_message_id, getNextRetryDelay(event.data.attempt));
break;
case "block":
// Infrastructure problem — alert ops, do NOT suppress the address
await alertOps({
smtp_code,
diagnostic,
affected_domain: address.split("@")[1],
});
// Check if this is auth-related
if (["5.7.1", "5.7.26", "5.7.28"].includes(smtp_code)) {
await triggerAuthDiagnostic();
}
break;
}
}
Reading the DSN diagnostic string
When you receive a DSN or a webhook bounce event, the diagnostic-code field is often the most informative. It's a free-text string from the receiving server. Some examples:
550 5.1.1 The email account that you tried to reach does not exist.
550 5.7.26 This message does not have authentication information or fails to
pass authentication checks.
452 4.2.2 The email account that you tried to reach is over quota.
Parsing these reliably requires pattern matching, not just checking the leading digit. The enhanced status code (the 5.1.1 part) is defined in RFC 3463 and is more reliable than the human-readable text, which varies by MTA. Write your classifier against the enhanced code, fall back to the leading digit (4 vs 5), and log the full diagnostic string for debugging.
function classifyBounce(smtpCode: string, enhancedCode: string): "hard" | "soft" | "block" {
// Block bounces: policy/auth failures
if (enhancedCode.startsWith("5.7.")) return "block";
if (enhancedCode.startsWith("4.7.")) return "block"; // Temporary policy rejection
// Hard bounces: permanent address failures
if (smtpCode.startsWith("5") && enhancedCode.startsWith("5.1.")) return "hard";
if (smtpCode.startsWith("5") && enhancedCode.startsWith("5.4.")) return "hard";
// Soft bounces: all other 4xx
if (smtpCode.startsWith("4")) return "soft";
// Unknown 5xx — treat conservatively as hard
return "hard";
}
Suppression list architecture
Your suppression list is not a simple blocklist. It needs enough context to make good decisions later.
Minimum schema:
CREATE TABLE email_suppressions (
address TEXT NOT NULL,
suppression_type TEXT NOT NULL, -- 'hard', 'soft_expired', 'complaint'
smtp_code TEXT,
enhanced_code TEXT,
diagnostic TEXT,
source_message_id TEXT,
suppressed_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
expires_at TIMESTAMPTZ, -- NULL = permanent
agent_id TEXT NOT NULL,
PRIMARY KEY (address, agent_id)
);
Before every send, your agent should check this table. For AI agents operating at high volume, a Redis bloom filter or in-memory TTL cache in front of the database query cuts latency significantly.
The sender reputation implications are direct: Mails.ai pauses an agent when its bounce rate exceeds 5% or complaint rate exceeds 0.3%. A well-maintained suppression list keeps those rates near zero by preventing repeat sends to known-bad addresses.
Complaint handling vs bounce handling
Complaints (spam reports via FBL — Feedback Loop) are not bounces, but they feed into the same reputation machinery and require the same suppression logic. The difference: a complaint means the address is valid but the recipient doesn't want your mail. Suppress on first complaint, with no expiry.
Some bounce webhooks conflate complaint events with block bounces when the receiving server routes FBL signals through SMTP rejection codes. Watch for 5.7.1 responses that include language like "user reported this message as spam" — those are complaint-driven blocks, and you should log them under complaint suppression rather than infrastructure failure.
Integrating bounce classification into agent decision logic
For agents doing anything beyond fire-and-forget sending — confirmation flows, follow-up sequences, two-way conversations — bounce classification needs to feed back into the agent's state machine.
Consider a scheduling agent that sends calendar invites. If the recipient's address hard-bounces:
- The agent should update its internal state: this contact is unreachable via email.
- It should check whether an alternative contact method exists.
- It should notify the user who initiated the scheduling request.
That's not bounce handling — that's the agent reasoning about a failure condition. The email infrastructure needs to surface bounce events as first-class typed events that the agent can act on, not just log to a metrics dashboard.
const hello = mails.agent("hello");
hello.onReply(async (event) => {
if (event.type === "message.bounced") {
const bounceType = classifyBounce(
event.data.smtp_code,
event.data.enhanced_code
);
// Feed classification back into agent state
await agentState.recordDeliveryFailure({
contact_id: event.data.metadata?.contact_id,
failure_type: bounceType,
is_permanent: bounceType === "hard",
});
if (bounceType === "hard") {
// Trigger fallback: try alternative contact method
await agentState.escalateToAlternativeChannel(event.data.metadata?.contact_id);
}
}
});
For a broader look at how agents handle delivery failures alongside other pipeline concerns, the email circuit breaker pattern pairs naturally with bounce classification — it prevents cascading failures when bounce rates spike.
Frequently Asked Questions
What's the difference between a hard bounce and a block bounce?
A hard bounce means the recipient address doesn't exist or is permanently unreachable — the problem is the address itself. A block bounce means the receiving server rejected your message based on sending policy: IP reputation, SPF/DKIM/DMARC failures, or blocklist entries. Hard bounces require suppressing the address. Block bounces require fixing your infrastructure. Confusing the two is a common and costly mistake.
Should I retry soft bounces immediately?
No. Immediate retries on soft bounces read as spam behavior to many receiving MTAs and can trigger rate-limiting or convert a temporary soft bounce into a policy-based block. Use exponential backoff starting at 5 minutes, with a maximum of 5-6 attempts over 48 hours. After that, temporarily suppress the address and re-enable after 30 days.
How do I detect block bounces caused by DMARC failures?
Look for enhanced status code 5.7.26 specifically — that's the IANA-registered code for DMARC policy violations. Some MTAs use 5.7.1 with diagnostic text containing "DMARC" or "dmarc". Check your DNS: dig TXT _dmarc.yourdomain.com and verify the policy is set correctly. If you're sending from a shared platform domain, alignment failures can happen when your envelope sender doesn't match your From header domain — check that SPF and DKIM are aligned to the same organizational domain.
How many bounces will get my sending domain suspended?
Google's Postmaster Tools documentation marks domains with bounce rates above 2% as impacted for Gmail delivery, with rates above 10% causing bulk folder classification. Mails.ai pauses an agent at a 5% bounce rate. Industry guidance from RFC 5321 and major ISP postmaster pages consistently treats sustained rates above 2-5% as a signal of poor list hygiene. The practical threshold for severe consequences is lower than most people assume — 100 hard bounces in 1,000 sends is enough to damage a domain's reputation.
Do I need to handle DSN messages directly, or will my sending API do it?
Most modern sending APIs parse DSNs and surface them as normalized webhook events, so you don't need to implement RFC 3464 DSN parsing yourself. What you do need to implement is the handler for those events — the classification logic and suppression list updates. The API normalizes the format; your code decides what to do with the information.
Can a bounce type change over time for the same address?
Yes. An address that returns a soft bounce (mailbox full) for days may eventually return a hard bounce if the account is closed. A domain that blocks you due to a blocklist entry may accept mail again after you delist. Build your suppression list with timestamps and re-evaluation logic rather than treating all suppressions as permanent. Only hard bounces with 5.1.x codes should be suppressed indefinitely without re-evaluation.
Related guides: Email Authentication Failures: Debug DKIM, SPF & DMARC, SPF Alignment Failures for Programmatic Senders, Email Unsubscribe Header Handling for AI Agents and Handle Bounce & Complaint Webhooks Automatically | Agent Email.
Explore the product: AI agent inbox API, Sender reputation, Email classification, All features and Pricing.
