All posts

What is an email thread, and how does threading work?

An email thread is a message and its replies. Here's how Message-ID, In-Reply-To and References hold it together, and why threads break.

An email thread is a message plus all the replies to it, shown together as one conversation. Mail apps build threads mainly from three headers on each message, Message-ID, In-Reply-To and References, and fall back to matching subject lines when those headers are missing.

This post covers how those headers work, why threads break, and how to send a reply that stays in the right conversation.

What is an email thread?

Each email is a separate message. Nothing in the mail system stores a conversation as one object. When you reply, your mail app sends a new message that points back at the one you're answering. Your app, and the other person's, read those pointers and draw the messages as one thread.

That's why the same conversation can look different in different apps. The messages are the same. Each app decides how to group them.

How do mail apps group messages into a thread?

RFC 5322, section 3.6.4 defines the three headers that do the work.

  • Message-ID is a unique label for one message, written in angle brackets, like <a1b2c3@mail.example.com>. The RFC says every message SHOULD have one, and the software that creates it MUST make sure it's unique.
  • In-Reply-To holds the Message-ID of the message you're replying to, which the RFC calls the parent.
  • References holds the parent's References list, followed by the parent's Message-ID. So each reply carries the whole chain of IDs back to the first message.

The RFC also says replies SHOULD have In-Reply-To and References, and that References "may be used to identify a 'thread' of conversation."

Here's how the chain grows. Dana writes in:

HTTP
Message-ID: <001@mail.northwind.example>
Subject: Invoice 4471 charged twice

Support replies:

HTTP
Message-ID: <002@support.example>
In-Reply-To: <001@mail.northwind.example>
References: <001@mail.northwind.example>
Subject: Re: Invoice 4471 charged twice

Dana replies to that:

HTTP
Message-ID: <003@mail.northwind.example>
In-Reply-To: <002@support.example>
References: <001@mail.northwind.example> <002@support.example>
Subject: Re: Invoice 4471 charged twice

Any app that has message 003 can place it in the thread, even if it never saw 002. The first ID in References is the root.

Why is subject-line grouping only a fallback?

Not every message has those headers. Some software doesn't set them, and some systems strip them. So apps also look at the subject.

IMAP, the protocol many apps use to read mail on a server, has a standard for this. RFC 5256 defines two threading methods. ORDEREDSUBJECT groups messages only by their "base subject", which is the subject with prefixes like Re: and Fwd: stripped off. REFERENCES builds parent and child links from the References and In-Reply-To headers first, then gathers messages that share a base subject.

Subjects make a weak key. Two unrelated emails called "Quick question" or "Invoice" share a base subject. One conversation whose subject someone edits no longer does. Headers point at exact messages. Subjects only look alike.

Apps also mix the two. Gmail's help page on conversation view says a conversation "breaks off into a new conversation when the subject line changes, or the conversation gets to more than 100 emails." Outlook's help page says "a conversation includes all messages in the same thread with the same subject line." In both, a changed subject can split a thread even when the headers link the messages.

Why do email threads break?

Most broken threads come from one of these.

A reply that's really a new message. If someone copies the address into a new email and types "Re:" by hand, there's no In-Reply-To or References. Apps that group by subject may still join it. Apps that rely on headers won't.

A changed subject. Editing the subject to "Re: Invoice 4471 (refund done)" keeps the headers, but Gmail and Outlook both treat the subject as part of what makes a conversation, so the reply can show up on its own.

Forwarding. A forward is usually a new message to someone new. Their copy has no earlier messages to attach to, so it starts a fresh thread for them. When they reply, their reply threads with the forward, not with the original conversation.

Mailing lists. List software often adds a tag to the subject, like [team], and may change other headers on the way through. If you reply to a digest, your In-Reply-To points at the digest, not at the message you meant to answer. You can also get two copies of the same reply, one sent to you directly and one through the list, with the same Message-ID.

Missing or reused IDs. If software sends a reply without the headers, or reuses a Message-ID, apps either lose the link or join messages that aren't related.

How do you reply so a message stays in the thread?

Three things:

  1. Set In-Reply-To to the parent's Message-ID.
  2. Set References to the parent's References, then add the parent's Message-ID at the end. If the parent has no References but has an In-Reply-To with one ID, use that ID followed by the parent's Message-ID. That's the rule from RFC 5322 section 3.6.4.
  3. Keep the subject. Add one Re: if it isn't there already. Section 3.6.5 says only one Re: ought to be used.

Your own reply also needs a new, unique Message-ID, so the next person can reply to it.

When you press Reply in a mail app, it does all of this for you. You only have to think about it when software sends the mail.

Why does threading matter for AI agents?

An agent that answers email is software sending mail, so it has to set the headers itself. If it sends its answer as a new message with the same subject, the customer may get a stray email that isn't attached to their question. Some apps may still group it by subject. Apps that go by headers won't, and the customer has to work out what the agent is answering.

The agent also needs the thread to do its job. A reply to the third message only makes sense with the first two in view. If replies land in new threads, the agent's history gets split in the same way.

How does ACK handle threads?

ACK is an email API for AI agents, so this is the part we built. When your agent replies to a message, ACK sets In-Reply-To and References, and the reply shows up in the same conversation in the sender's mail app. Take the message_id from the incoming message and call reply:

Shell
curl https://api.ack.now/v0/inboxes/support-agent@trial.ack.now\
/messages/$MESSAGE_ID/reply \
  -H "Authorization: Bearer $ACK_API_KEY" \
  --json '{"text": "Found the duplicate charge and refunded it."}'

If a person should check the reply first, the agent can save a draft with in_reply_to set to the message it's answering. ACK copies the recipient and the subject from that message and puts the draft in the same thread:

Shell
curl https://api.ack.now/v0/inboxes/support-agent@trial.ack.now\
/drafts \
  -H "Authorization: Bearer $AGENT_KEY" \
  --json '{"in_reply_to": "<CAH7f2…@mail.northwind.co>",
           "text": "Found the duplicate charge and refunded it."}'

Incoming mail is grouped into threads too, and each webhook delivery includes the thread the message belongs to. Mail you import from an mbox file, a zip of .eml files or an IMAP server is threaded the same way as live mail. Over MCP, reply_to_message and create_draft do the same as the REST calls.

How to give an AI agent its own email address walks through the whole loop, and Approve your agent's email before it goes out covers drafts. The endpoints are on the developers page.

FAQ

What's the difference between an email thread and a conversation?

Usually nothing. "Thread" is the general term. Gmail and Outlook both call the grouped view a conversation.

Can I turn email threading off?

In most apps, yes. Gmail has a Conversation View setting, and Outlook has "Group messages by conversation" and "Do not group messages" options. The headers are still on each message, so turning threading off only changes how your app shows them.

Why did my reply start a new thread?

The usual reasons are a changed subject, a forward, or software that sent the reply without In-Reply-To and References. Check the raw headers of the reply. If they're missing, the sender's software didn't set them.

Does Reply All stay in the thread?

It should. Reply All is still a reply, so the mail app sets the same In-Reply-To and References. It only changes who gets the message.

Try it

ACK is $19 a month per organisation, with 10 inboxes and every feature on the one plan. Start a 14-day trial and send your agent's first threaded reply.