Keep your app's notification emails in tidy threads
Short answer: If your app's notification emails about one order, ticket or project scatter across a customer's inbox, or unrelated alerts collapse into one giant conversation, set the threading headers deliberately. Give every email a unique Message-ID, and when a message belongs to an ongoing conversation, set In-Reply-To and References to the IDs of earlier messages in it, with a consistent subject line. Messages that should stand alone need distinct subjects and no references.
Why threading goes wrong
Mail apps group messages into conversations using a mix of signals. The standard ones are headers defined in RFC 5322, the internet message format. Many apps also look at the subject line, and each mail app applies its own rules on top.
Business apps often get this wrong in one of two directions:
- Scattered updates. "Order confirmed", "Order shipped" and "Order delivered" for the same order arrive as three separate conversations, so the customer can't see the history at a glance.
- Accidental mega-threads. Every "New enquiry" notification has the same subject, so the office inbox shows one conversation with three hundred unrelated enquiries in it, and replies go to the wrong person.
Both come from leaving threading to chance.
The headers that matter
RFC 5322 describes three fields:
Message-IDcontains a single unique identifier for the message. The standard says this identifier must be globally unique and that whoever generates it must guarantee its uniqueness.In-Reply-Tonames the message (or messages) this one replies to.Referenceslists the chain of message IDs in the conversation so far.
The standard says every message should have a Message-ID, and reply messages should have In-Reply-To and References as appropriate. Mail apps use these to link messages together.
Designing threads for your notifications
Decide which emails belong to the same conversation from the reader's point of view. Usually that's one thread per object: per order, per support ticket, per booking or per project.
For each object:
- Generate a stable root ID, for example
<order-48213@notifications.example.com>, and use it as theMessage-IDof the first email about that object. - For each later email, give it its own new unique
Message-ID, and setIn-Reply-Toto the root (or to the previous message) andReferencesto the root plus any earlier IDs. - Keep the subject consistent, such as "Your order #48213", optionally with a short status word added at the end. Some mail apps also require matching subjects; Google's Gmail API documentation, for instance, says that for a message to join a thread through its API, the References and In-Reply-To headers must be set correctly and the subject headers must match.
- Store the IDs you've sent with the order or ticket record, so you can reference them later.
For emails that should never group, such as separate enquiries from different customers, make subjects distinct by including a name, reference number or short summary, and don't add References.
Message-ID format
A message ID looks like an email address in angle brackets: a unique left part, an @, and a domain. Use a domain you control, such as your sending subdomain, and a left part that can't repeat, such as a random value combined with the object's ID. Many email libraries and sending services generate a Message-ID automatically; if you want stable roots, check that yours lets you set it explicitly, and that it doesn't overwrite your value.
Replies from customers
If customers reply to notifications, threading headers help your side too. When a reply arrives, its In-Reply-To and References tell your system which original message it answers, which is more reliable than matching on subject. If you route replies into a helpdesk or the app itself, record the outgoing IDs so incoming replies can be matched. Use a reply address that actually reaches someone or something, rather than a dead no-reply box, if you invite replies.
Testing across mail apps
Threading differs between mail apps, so test where your customers read email:
- Send a sequence of three notifications for one test order and check they group in the main webmail services and phone mail apps.
- Send two notifications for different orders and check they stay separate.
- Reply to one and check the reply lands in the right place on your side.
Look at the raw headers of received messages to confirm your IDs survived the sending service unchanged.
Common pitfalls
- Reusing the same
Message-IDfor every email. Some systems drop or merge duplicates, and threads become unpredictable. - Identical generic subjects for every notification, creating mega-threads.
- Prefixes that change the subject, such as adding "Update:" to some and not others, which can split threads in apps that match subjects.
- Different sending domains for messages in the same thread, which can confuse some apps.
A worked example
Picture a hypothetical Galway property-maintenance company whose tenant portal emailed landlords about each repair job: logged, scheduled, completed. Each email had a different subject and no threading headers, so landlords received scattered messages and replied to the wrong one. The developer created a root message ID per job, added In-Reply-To and References to later updates, standardised subjects to "Repair job #1042 at 14 Dock Road", and stored the IDs with each job. Landlords now see one conversation per job, and replies are matched to the right job automatically.
FAQ
Do I need these headers for marketing emails?
Usually not. Newsletters are meant to stand alone. Threading matters for transactional sequences.
Will threading headers affect deliverability?
Correct, unique message IDs are normal and expected. Missing or malformed ones can look suspicious to some filters.
Can I change how one specific mail app threads?
Not directly. Consistent headers and subjects give the best results across apps.
What if my sending service rewrites Message-ID?
Check its documentation for a way to set custom headers, or use its own identifiers for matching replies.
If your app's notifications confuse customers more than they help, tell us what it sends and we'll help tidy the flow.