Use 5xx Status Code to Represent Mailgun Hard Bounce in API-Driven Verification
Learn how to map Mailgun's hard bounces to HTTP 5xx status codes in API-driven verification. Reduce bounces, improve sender reputation, and maintain clean.
Why Hard Bounces Matter More Than You Think
You sent 5,000 emails last week. Five hundred bounced. You assumed they were all temporary—maybe a full inbox, a server hiccup. But what if half of them were permanent failures? What if those weren’t just delivery hiccups, but signs your list was decaying?
Hard bounces aren’t just a nuisance. They’re the technical signal that an email address no longer exists, is permanently unreachable, or has been shut down. If your API-driven verification treats them as soft bounces—or worse, ignores them entirely—it’s like shipping goods to a non-existent warehouse. You’re burning bandwidth, degrading reputation, and risking blacklisting.
The truth is, correctly classifying hard bounces with a 5xx status code (like Mailgun’s hard_bounce) is foundational to maintainable list hygiene. It’s not a tiny detail—it’s the difference between a clean, effective campaign and one that drags down your sender reputation.
Key takeaways
- A 5xx status code in Mailgun’s API should be mapped to hard_bounce to ensure accurate filtering of permanently invalid addresses.
- Failure to distinguish hard bounces from soft ones inflates bounce rates and damages sender reputation over time.
- API-driven verification systems must validate and classify 5xx response codes as hard_bounces to preserve deliverability and prevent list decay.
What Does a 5xx Status Code Mean in Email Verification?
When your API receives a 5xx status code from Mailgun during email verification, it means the recipient’s server permanently rejected the email—this is a hard bounce. Unlike temporary issues, 5xx responses signal server-side failures that will not resolve on their own. You should treat this outcome as a definitive signal to remove the address from your list.
Server Errors Are Permanent Failures
HTTP 5xx status codes indicate problems on the receiving server’s side—not your system. These aren’t delays, timeouts, or rate limits; they represent errors like invalid domains, disabled accounts, or blocked mail servers. In email delivery, a 5xx response from a provider like Mailgun is a red flag that the address is irrecoverably broken.
For example, if Mailgun returns a 550 error (which is within the 5xx range) saying “User unknown,” that’s a hard bounce by definition. The SMTP protocol explicitly treats such responses as permanent failures—no retry will change that. This is why systems like Email List Validation use 5xx codes as a reliable signal to classify an address as invalid.
Let’s be clear: you can’t fix what the server refused to accept. The mailbox doesn’t exist, or the domain refuses all inbound mail. These are not transient issues. If your verification system sees a 5xx, it should not attempt delivery again—just flag the address as undeliverable and remove it.
Why This Matters in Real-World Verification
Many email verification services misclassify 5xx errors as temporary or uncertain, leading to wasted sends and damaged sender reputation. But in practice, 5xx codes are among the most reliable indicators of a hard bounce. They reflect decisions made at the receiving end—like filtering by domain policy, strict spam thresholds, or account deactivation.
According to the IETF’s SMTP RFC 5321, permanent failures are marked with 5xx responses and must be treated as non-retryable. It’s not a suggestion—it’s the standard. When your API hits one, you’re seeing a final rejection from the mail server itself.
This is why tools that map 5xx codes to hard_bounce status—like real-time email verification—help prevent send fatigue and reduce blacklisting risk. By acting on these signals early, you maintain sender health and improve inbox placement over time.
How Mailgun Uses Hard Bounce Responses in Its API
Mailgun signals hard bounces through API responses with a status field set to rejected or failed, but it does not expose the underlying SMTP 5xx response codes (like 550 or 553) directly in the JSON payload. This means you must interpret these statuses as hard bounces using your own logic, often treating them as equivalent to HTTP 5xx errors when validating email lists programmatically.
Why SMTP Codes Are Not Exposed
Mailgun abstracts the raw SMTP-level reply codes into a simplified status model for easier integration. While the RFC 5321 specifications define 5xx codes as permanent failures—such as invalid recipients, closed domains, or blacklisted IPs—Mailgun’s API does not pass these codes through directly. This limits your visibility into the exact reason for rejection, which can complicate diagnostic workflows.
Let’s say you receive a failed status from Mailgun. That’s your signal to treat the address as undeliverable. But without access to the original 550 or 553 code, you can’t distinguish between a user who no longer exists and a domain that’s permanently blocked. For automated validation pipelines, this lack of granularity requires you to infer the failure type based on the status alone.
Mapping to 5xx Status Codes in Validation Pipelines
Because hard bounces represent permanent delivery failures, treating them as 5xx HTTP errors makes sense in API-driven systems. This mapping aligns with common practices in web service design: 5xx codes indicate server-side problems, and in email validation, a hard bounce is a permanent failure that should not be retried.
This interpretation is consistent with industry guidance on email deliverability. The Internet Message Format (RFC 5321) explicitly defines 5xx codes as permanent failures, and systems like Return Path or MxToolbox rely on similar models for reputation scoring and bounce analysis.
When building validation systems, you can use this pattern to filter out addresses flagged as rejected or failed in Mailgun’s API and mark them as hard bounces in your database. This avoids future delivery attempts and helps maintain sender reputation.
For more precise filtering and real-time insights, tools like real-time email verification can cross-check against live SMTP responses, catch-all detection, and disposable domains—giving you more context than Mailgun’s abstracted status alone.
Why You Should Use 5xx to Represent Hard Bounces in Your Code
Using a 5xx status code for Mailgun hard_bounces in your API-driven verification makes the failure permanent and unambiguous. It tells your system, “This address is dead,” without confusion from temporary issues like server timeouts or rate limits.
Signal Permanent Failure with Standard HTTP Behavior
HTTP status codes aren’t just for web servers—they’re part of a shared language. When you return a 5xx error, you’re signaling a server-side problem that won’t resolve on retry. A hard bounce from Mailgun fits this model: the recipient’s domain or mailbox no longer exists, so retrying does nothing.
If you use 2xx or 4xx for hard bounces, you risk mixing transient and permanent issues. That leads to wasted retries, degraded delivery performance, and misinformed reporting. By reserving 5xx for hard bounces, you ensure logic downstream treats the address as invalid—no exceptions, no retries.
Enable Predictable, Scalable Processing
When your verification API returns a 5xx code, the downstream system knows exactly what to do: remove the email from the list, flag it in logs, and optionally send an alert. This consistency is critical at scale.
Think about it: if every system handling verification uses the same standard, you avoid custom logic per integrator. It’s not about opinion—it’s about interoperability. The HTTP/1.1 specification clearly defines 5xx as server errors, making this choice not just clean, but compliant.
That same principle applies to third-party tools. Our real-time verification API returns structured verdicts—including hard bounce detection—so you can build reliable pipelines from the start, without layering workarounds.
Let’s be clear: using 5xx for hard bounces isn’t about performance optimization. It’s about clarity. It reduces cognitive load across your development and operations teams. And it prevents subtle bugs that only surface after sending thousands of messages.
Use status codes to convey meaning. Don’t abuse 4xx for permanent failures. Let 5xx be the signal that the address is gone for good.
That level of predictability is what keeps email deliverability reliable—and that’s something your team, your business, and your deliverability reputation need. When you use the right code, you’re not just building faster logic—you’re building trust in your system’s decisions.
How to Map Mailgun Hard Bounces to 5xx in Your Verification Pipeline
When Mailgun returns a hard bounce—like a 550 error signaling a permanently rejected email—your API-driven verification system should respond with an HTTP 5xx status code. This signals to clients that the email is invalid and should not be retried. Use the SMTP error code from the response for debugging and logging, and mark the address as invalid in your database. This keeps your sender reputation intact and reduces waste.
Map Hard Bounces to 5xx Status Codes
- Call the Mailgun API with a target email address. Use the
messagesendpoint to test deliverability or check status of a specific email. This is how you trigger a real-world delivery attempt from your verification pipeline. - Check the response for rejection statuses like
rejectedorfailed. Mailgun’s API returns structured error data. Look for fields likestatusandsmtp_errorto determine if the failure is permanent. Afailedstatus with a 5xx-level SMTP code typically indicates a hard bounce. - Return a 5xx HTTP status code if retry isn't possible. If the error is a hard bounce—e.g., "550 5.1.1 User unknown"—treat it as a fatal failure. Return
500 Internal Server Erroror503 Service Unavailableto the client. This prevents further attempts and aligns with HTTP semantics for server-side issues. - Log the SMTP error code for audit and debugging. Include the actual SMTP code (like 550, 551, or 552) in your logs. This helps you track patterns, improve filtering, and debug delivery issues. For example, a 550 error often means the mailbox doesn’t exist. You can learn more about SMTP error codes from the official SMTP RFC.
- Mark the email as invalid in your list hygiene system. After confirming a hard bounce, update your database to flag the email as undeliverable. This reduces future bounce rates, protects sender reputation, and improves overall deliverability. Consider syncing this state with tools like bulk email list cleaning to maintain list quality at scale.
Why This Matters for Deliverability
Using 5xx codes for hard bounces ensures your API behaves predictably and follows HTTP standards. Unlike soft bounces (e.g., 4xx errors), hard bounces should not be retried. Over time, consistent handling of these errors reduces your risk of being flagged by inbox providers. It also helps maintain clean data, which is essential for email deliverability. Tools like real-time verification APIs help you catch and act on these signals early, reducing the chance of misclassification. Always validate against real-world delivery behavior—not just syntax.
The Risk of Misclassifying Bounces
Using a 5xx status code for Mailgun hard_bounces in API-driven verification isn’t just technical rigor—it’s essential. Mistaking a hard bounce for a soft success (2xx or 4xx) keeps invalid addresses in your list, inflates your hard bounce rate, and can trigger spam filters on platforms like Gmail or Outlook. This misclassification damages sender reputation and reduces inbox placement over time.
Why the Wrong Status Code Hurts Your Deliverability
When a hard bounce occurs—meaning the email address doesn’t exist or the domain rejects mail entirely—returning a 2xx or 4xx status code falsely signals success or temporary failure. You end up hanging onto dead addresses, which silently degrade your sender reputation. Major email providers like Google and Microsoft track consistent hard bounce patterns as indicators of poor list hygiene. If your outbound volume includes many false positives, they’ll start suppressing your messages or flagging your IP.
Let’s say your system logs a hard bounce as a 4xx error because it doesn’t map the response correctly. Over time, this inflates your bounce rate reports, even though you're not hitting actual delivery issues. Platforms like Microsoft’s SmartScreen or Spamhaus monitor these metrics. A high hard bounce rate—even if incorrectly reported—signals low-quality mail practices, increasing the risk of being placed in quarantine.
Correct Mapping Preserves Sender Reputation
Returning a 5xx status code ensures that every hard bounce is treated as a definitive failure. This consistency prevents false positives and keeps your deliverability metrics accurate. It’s not about catching every error—it’s about classifying them right before they impact your sender reputation.
Industry standards, such as those outlined in RFC 6520, define 5xx status codes for server-side failures. Applying this to Mailgun’s hard_bounce response aligns your system with established email transport protocols. The result? Cleaner data, fewer blocklist risks, and better inbox placement.
For teams managing bulk sends, this accuracy isn’t optional. Tools like bulk list verification catch invalid addresses before they ever hit your sending engine. They don’t just check syntax—they test deliverability at scale using real SMTP transactions. This prevents misclassification from the start.
Real-World Verification Logic in Email List Validation
You can use a 5xx status code to represent a Mailgun hard_bounce in API-driven verification because it signals a permanent delivery failure — the email address doesn’t exist or is permanently rejected. We validate this using real SMTP interactions and upstream provider feedback, ensuring only deliverable addresses survive. Our system achieves 98.9% accuracy by correctly flagging hard bounces, including those from Mailgun, through precise 5xx status classification.
How We Treat Hard Bounces from Mailgun
When an email is sent through Mailgun, a 5xx SMTP status code means the receiving server has definitively rejected the message — often because the recipient address is invalid or the domain doesn’t accept mail. We capture and interpret these responses exactly as they arrive. This isn’t an inference; it’s a direct reading of the upstream provider’s behavior.
Using 5xx codes as a signal for hard_bounce isn’t arbitrary. It aligns with standard SMTP protocols — a 5xx response means "permanent failure," which is what RFC 5321 defines as a hard bounce. You’ll see the same pattern in other providers like SendGrid or Amazon SES. The key is consistency: if the upstream says it’s dead, we mark it as dead.
Precise Logic Behind 98.9% Accuracy
Our verification process doesn’t guess. It uses real-time SMTP probing and respects the outcome of each server-to-server interaction. If Mailgun returns a 5xx, we classify it as hard_bounce with full confidence. This prevents any false positives — no risky or undeliverable addresses slip through.
By treating 5xx status codes as hard bounce indicators, we reduce false retention of invalid addresses, which directly improves list hygiene. Clean lists mean higher deliverability and fewer wasted sends. This isn’t a workaround — it’s a direct, standards-compliant practice that mirrors how email infrastructure actually works.
For example, when you run a bulk verification on our bulk email list cleaning tool, you’re not just scoring addresses — you’re validating them against real delivery behavior. We also support real-time check via our real-time email verification API, which integrates this same logic into your workflow. The result? Fewer bounces, better sender reputation, and measurable improvements in inbox placement.
Learn more about how verification impacts sender reputation and email delivery: Spamhaus and RFC 5321 provide industry-standard references on SMTP and abuse prevention.
Integrating with Mailgun, SendGrid, and Other ESPs
You can use the 5xx status code to represent Mailgun hard bounces in API-driven verification because SendGrid and AWS SES already use 5xx for hard bounces—aligning with Mailgun ensures consistent handling across ESPs. This consistency simplifies bulk verification logic and list cleanup, especially when processing real-time or batch validation results.
Why Status Code Consistency Matters
When your system treats 5xx as a hard bounce across all ESPs, you avoid writing different logic for each platform. Mailgun uses 5xx for permanent delivery failures—like invalid domains or non-existent addresses—just as SendGrid and AWS SES do. This isn’t arbitrary; it follows standard HTTP semantics where 5xx indicates a server error, which applies to permanent email rejection.
For example, if Mailgun returns a 5xx error, your system assumes the address is dead and removes it from campaigns. Doing this consistently across ESPs keeps your data clean and your send rates high. Without alignment, you risk misclassifying bounces, leading to unnecessary retries or over-aggressive suppression.
How Email List Validation Fits In
Our tool supports integrations with Mailchimp, HubSpot, Klaviyo, and SendGrid—so you can validate lists right where you manage campaigns. You can push cleaned addresses back into these platforms, reduce bounces, and improve sender reputation.
Using the same status code rules (like 5xx for hard bounces) in your verification flow makes it easier to map results from Email List Validation to your existing ESP logic. You get accurate, actionable feedback: valid, invalid, catch-all, or risky—each with clear, measurable outcomes.
Real-time email verification via our API or bulk processing through bulk verification ensures you’re not sending to addresses that will fail. Many ESPs, including Mailgun, treat hard bounces as a signal for sending reputation, so catching them early improves inbox placement.
While ESPs vary in how they report errors, standards like RFC 5321 and RFC 5322 define how email delivery failures should be handled. The use of 5xx for hard bounces is an industry-standard implementation, not a workaround. You can verify this behavior by checking SMTP error codes in RFC 5321, where 550 (no such user) is a well-known hard bounce.
What Each Verification Verdict Really Means
You’re not just filtering bad emails — you’re mapping deliverability risk. Each verdict tells you exactly how to act: Valid means send, Invalid means scrap, Catch-all means verify manually, Risky means pause, and Hard Bounce (5xx) means remove immediately. A 5xx status in API-driven verification is a hard server-level rejection — treat it like a permanent block, not a retryable error.
Core Verdicts and Their Real-World Impact
- Valid: The email is syntactically correct, the domain exists, and the mail server accepts messages. No known issues. You can send to it with confidence. This is inbox-ready.
- Invalid: Detected syntax error, non-existent domain, or confirmed hard bounce. These are dead ends. Remove them immediately. An invalid email will always fail and hurt sender reputation. SMTP RFC 5321 defines syntax requirements — if the server rejects it, it doesn’t pass basic validation.
- Catch-all: The domain accepts all emails, but we can’t confirm inbox reachability. These are high-risk: they might deliver, or might not. Use only if you’re verifying at scale and don’t need delivery proof. Consider this a placeholder — follow up manually or exclude.
- Risky: Indicates use of role accounts (e.g. sales@, support@), disposable domains, or known spam trap behavior. These often trigger filters or blocklists. High false-positive risk. Either avoid or verify through human review.
- Hard Bounce (5xx): Permanently rejected by the recipient server. This isn’t temporary — it won’t become deliverable. Treat it with urgency. If your API returns a 5xx status code during verification, it’s a hard bounce. Do not retry. Remove instantly from your list.
Why 5xx Matters in Real-Time Verification
Many tools treat 5xx responses as generic errors. Not here. In our system, 5xx status codes directly map to hard bounces — confirmed server-level rejections. You’re not guessing; you’re acting on a verified signal. You can trust this data to clean your list with precision. This is not just a flag — it’s a hard stop in the delivery chain.
For developers using API-driven workflows, integrating 5xx detection ensures your system never sends to a confirmed dead endpoint. It’s a critical step in maintaining sender reputation. If you’re building a system that verifies lists at scale, our real-time API checks for 5xx responses and returns them as hard bounces — no exceptions. We don’t ignore server signals. We act on them.
Use 5xx Status Codes to Improve List Quality and Deliverability
Mapping Mailgun hard bounces to 5xx status codes ensures your system treats invalid or permanently failed email addresses as server-level errors—not transient issues. This correct classification prevents re-attempts, reduces bounce rates, and protects sender reputation, which directly impacts inbox placement. If you’re building an API-driven verification layer, treating hard bounces as 5xx signals precision in list hygiene.
Why 5xx Matters for Deliverability
When Mailgun returns a hard bounce, it means the recipient’s mail server has definitively rejected the email—often due to a non-existent address or policy restriction. Using a 5xx status code (like 550 or 554) correctly flags this as a permanent failure, not a temporary one. Mislabeling these as 4xx codes can lead to retry logic that wastes bandwidth and harms your sender reputation.
Industry standards, including those from the IETF and major email providers, treat 5xx responses as unambiguously fatal. This consistency is what ISPs and inbox providers rely on to filter out problematic senders. If your system misinterprets hard bounces, you risk being flagged as a poor sender—even if you’re not.
Enforcing Proper Mapping with Real-Time Verification
Let’s say you’re using Mailgun to deliver campaigns. If your system processes hard bounces without mapping them to 5xx, you may still attempt delivery to invalid addresses, especially if legacy routing doesn’t validate at origin. That’s where real-time verification comes in.
You can use Email List Validation’s real-time email verification API to check addresses before they enter your sending pipeline. It detects hard bounces before they happen by validating syntax, domain existence, and inbox reachability. If an address fails, it returns a clear status—like invalid or hard_bounce—so you map it accurately to a 5xx code in your API.
For larger lists, bulk verification lets you clean your entire database at scale, identifying and removing dead addresses before you send. This upfront cleanup means fewer actual hard bounces, lower sending costs, and stronger long-term deliverability. It’s not just about avoiding bounces—it’s about building a sender reputation based on reliability, not luck.
When you enforce 5xx mapping, you’re not just fixing code—you’re reinforcing trust with email providers. And that’s how you get into inboxes, not spam folders.
The Bottom Line: Clean Lists Start with Correct Classification
Only accurate email classification reveals which addresses are truly unreachable. Mislabeling a hard bounce as soft—or ignoring it entirely—leads to wasted sends, poor sender reputation, and lower inbox placement.
Why the 5xx Status Code Matters
Using a 5xx status code to represent Mailgun hard bounces in API-driven verification isn’t just technical precision—it’s a defensive measure. It ensures your system treats permanent failures as such, preventing retries and reducing strain on reputation systems.
- 5xx errors indicate server-level failures, such as non-existent recipients or rejected domains.
- Correctly identifying these allows you to remove dead addresses before delivery.
- Consistent classification across tools and platforms improves long-term deliverability.
Keep reading
- Bounce management: hard bounces, soft bounces and bounce rate (complete guide)
- Automated Email Deliverability Monitoring for 550 5.7.1 SASL Authentication Issues
- Normalize Soft Bounce Messages from Mailgun and Amazon SES for Analytics
- Email Validation API for Reducing 451 4.4.2 Errors in Mass Mailings
- Email Validation API for Troubleshooting 550 5.1.8 in SendGrid
Ready to put this into practice? Email List Validation verifies emails with 98.9% accuracy — start with 100 free verifications.
Frequently asked questions
What does a 5xx status code mean in Mailgun's email verification API?
A 5xx status code indicates a server-side error, such as a permanent bounce. In verification logic, it maps to a hard bounce—meaning the address is permanently unreachable and should be removed.
Should I treat Mailgun hard bounces as 5xx in my system?
Yes. Mapping hard bounces to 5xx status codes aligns with HTTP standards and ensures accurate list hygiene. It helps distinguish permanent failures from transient issues.
How does Email List Validation handle hard bounces from Mailgun?
We detect and classify hard bounces from Mailgun using 5xx status codes. Our 98.9% accuracy includes precise classification of invalid, catch-all, and risky addresses.
Why is classifying hard bounces important for deliverability?
Unremoved hard bounces inflate your bounce rate, harm sender reputation, and increase the risk of being blacklisted by ISPs.
Can I integrate Email List Validation with Mailgun?
Yes. Email List Validation integrates with Mailgun and other ESPs via API, enabling automated verification and real-time list cleanup.
What’s the difference between a hard bounce and a soft bounce?
A hard bounce means the address is permanently invalid. A soft bounce is temporary — the server is unreachable or full. Soft bounces may be retried; hard bounces should be removed immediately.
Do 5xx status codes apply to all email providers?
The principle applies broadly. Providers like SendGrid and AWS SES use 5xx for hard bounces. Email List Validation applies this logic consistently across ESPs.
How do I start verifying my list with Email List Validation?
Begin with 100 free verifications. Upload your list, and we’ll return verdicts with 98.9% accuracy — including hard bounce classification via 5xx status codes.
What happens to emails classified as hard bounces?
They are marked as invalid. You should remove them from your list to maintain clean data and improve deliverability.
Do credits expire in Email List Validation?
No. Purchased verifications never expire. You can use them at any time, even months later, without loss.
Can I use Email List Validation to test inbox placement?
Yes. In addition to verification, we offer inbox-placement testing to assess how well your emails land in inboxes across major providers.
What should I do with catch-all or risky addresses?
Treat them as low trust. Exclude them from campaigns or test them separately. Avoid sending to them in bulk.