# Classify an SMTP reply

Read the reply code and enhanced status code, and tell a temporary failure from a permanent one.

Canonical: https://1loc.dev/email/classify-an-smtp-reply/
Version: 1.0.0
Runtime: JavaScript · Node.js 22 / modern browsers
Verification: Local fixtures; no external services
Updated: 2026-10-28

## Implementation

```javascript
function classifySmtpReply(reply) { const [, code, enhanced] = /^([2-5]\d{2})(?:[ -]([245]\.\d{1,3}\.\d{1,3}))?/.exec(reply); return { code: Number(code), enhanced: enhanced || null, outcome: { 2: 'success', 3: 'intermediate', 4: 'transient', 5: 'permanent' }[code[0]], retry: code[0] === '4' }; }
```

## Input

```json
"550 5.1.1 The email account that you tried to reach does not exist"
```

## Expected output

```json
{
  "code": 550,
  "enhanced": "5.1.1",
  "outcome": "permanent",
  "retry": false
}
```

## Edge case

Input:
```json
"451 4.7.1 Try again later"
```
Output:
```json
{
  "code": 451,
  "enhanced": "4.7.1",
  "outcome": "transient",
  "retry": true
}
```

## Limits

- Reply classes follow RFC 5321: 2xx success, 3xx intermediate, 4xx transient, 5xx permanent. Enhanced codes (RFC 3463, class.subject.detail) refine the reason; servers may omit them.
- The sending server retries transient replies, not your application. With Oveyon, act on the per-recipient state it reports — such as deferred or bounced — instead of parsing SMTP text yourself.

The lab validates types and size before calling this function. Add equivalent validation at your own trust boundary.

## Source and license

Author: Oveyon, written for this edition; not part of the original 1loc collection.
Copyright (c) 2026 Oveyon
License: MIT — https://1loc.dev/licenses/
Maintainer: Oveyon
