# Email mailbox parse

`email-mailbox-parse` · version 1.0.0 · Communications · free, no key needed

Parse one RFC 5322 mailbox into parts and canonical text, without a delivery claim.

**Use when you need to: parse rfc 5322 mailbox · split mailbox display name into words · extract mailbox local part and domain.**

## Decide before calling

Read the [versioned contract](/v1/tools/email-mailbox-parse/versions/1.0.0) and the supported scope below. Reuse `email-mailbox-parse@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `email-mailbox-parse@1.0.0` for parse rfc 5322 mailbox. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- parse rfc 5322 mailbox
- split mailbox display name into words
- extract mailbox local part and domain
- decode quoted mailbox local part
- count comments in an email mailbox
- read addr-spec or name-addr parts
- פירוק תיבת דואר למבנה

## Not supported

- look up DNS or claim the mailbox can receive mail
- decode RFC 2047 encoded-words
- parse a mailbox list or a group
- convert a domain to punycode

## Behavior

- One mailbox only: name-addr or addr-spec from RFC 5322 section 3.4.1. Display-name is a phrase of one or more words, and each word is one atom or one quoted-string (sections 3.2.3 and 3.2.4), with CFWS between words. A leading quote starts only that quoted-string; later words are parsed separately.
- Dot-atom, quoted-string, comments, and domain-literals are accepted. Obsolete phrase dots, obsolete routes, lists, and groups are rejected. FWS inside a quoted-string keeps its space and tab characters and drops CRLF. Canonical text quotes a word or local-part only when it is not an atom or dot-atom, and it omits comments.
- display_words keeps the source word form. display_name and canonical use that canonical quoting. Case is preserved. utf8 defaults to false; true allows RFC 6532 section 3.2 UTF-8 scalars in atoms, quoted strings, comments, and domain literals, with no Unicode normalization and no IDNA.
- No DNS lookup, no mailbox-existence check, and no deliverability claim. Limits are enforced before or as soon as a component exceeds its cap.

## Input

- `mailbox` (string, required): min length 1; max length 256
- `utf8` (boolean, optional)

## Output

- `form` (one of "addr-spec", "name-addr", required)
- `local_part` (string, required): min length 0; max length 64
- `local_form` (one of "dot-atom", "quoted-string", required)
- `domain` (string, required): min length 0; max length 190
- `domain_form` (one of "dot-atom", "domain-literal", required)
- `display_name` (string or null, required): max length 1200
- `display_words` (array of object, required): max items 8
- `comment_count` (integer, required): min 0; max 8
- `canonical` (string, required): min length 3; max length 1600
- `utf8_mode` (boolean, required)

## Limits

- max mailbox bytes: 256
- max local part chars: 64
- max domain chars: 190
- max display words: 8
- max word chars: 64
- max comment depth: 4
- max comments: 8
- max output bytes: 2048

## Example

Request input:

```json
{
  "mailbox": "John Doe <jdoe@machine.example>"
}
```

Response:

```json
{
  "result": {
    "form": "name-addr",
    "local_part": "jdoe",
    "local_form": "dot-atom",
    "domain": "machine.example",
    "domain_form": "dot-atom",
    "display_name": "John Doe",
    "display_words": [
      {
        "form": "atom",
        "text": "John"
      },
      {
        "form": "atom",
        "text": "Doe"
      }
    ],
    "comment_count": 0,
    "canonical": "John Doe <jdoe@machine.example>",
    "utf8_mode": false
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "email-mailbox-parse",
  "version": "1.0.0",
  "input": {
    "mailbox": "John Doe <jdoe@machine.example>"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/email-mailbox-parse/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"mailbox":"John Doe <jdoe@machine.example>"}'
```

The machine-readable contract is at [/v1/tools/email-mailbox-parse/versions/1.0.0](/v1/tools/email-mailbox-parse/versions/1.0.0).

### CLI

```sh
node cli.mjs run email-mailbox-parse 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Email mailbox format](/tools/email-mailbox-format): Render a canonical RFC 5322 mailbox from decoded parts, without a delivery claim.
- [Email address list parse](/tools/email-address-list-parse): Parse an RFC 5322 address-list into ordered mailboxes, groups, and a canonical form.
- [Email address list deduplicate](/tools/email-address-list-deduplicate): Drop duplicate mailboxes in an RFC 5322 address-list, keeping the first one.
- [Email address list format](/tools/email-address-list-format): Format mailboxes and groups as one deterministic RFC 5322 address-list.
- [Email address list validate](/tools/email-address-list-validate): Check RFC 5322 address-list syntax, including dots, quotes, comments, and groups.
- [Email mailbox validate](/tools/email-mailbox-validate): Check one RFC 5322 mailbox for syntax only and return a stable reason code.
