Search code examples
emailmimeemail-headers

Force a new email thread


When writing an application that sends email based on certain events, I would like to enforce the rule that each of these emails starts a new "conversation".

Email systems such as Gmail like group email messages into "conversations", such that messages A is presumed to be a reply to message B. There's lots of methods they use to determine what message you're replying to, such as the Subject: header or the In-Reply-To: header.

However, since automated emails tend to sometimes reuse subject lines (e.g. "Monitoring failure on server foo.bar.com"), often the mail service will assume that a given email is actually a reply to a previous message with the same subject line, even though the two are unrelated. This can lead to confusion and clients potentially missing an important notification.

Is it possible (and if so, then how) to signal in your mail headers that a given email is NOT a reply to any other, despite any potential similarities in the subject lines?

Since the email subject itself is visible to the client, I would prefer to avoid silliness like this: "Subject: Automated reminder for $task [".md5sum(date())."]"


Solution

  • There isn't really a way to do this for all email systems. Even if you do figure out how to get around it for Gmail, what about Mail.app's, Thunderbird's, and Outlook's threaded conversation modes? Certainly each mail client that supports such functionality determines messages' membership to a given conversation differently.

    That being said, it appears that most clients use a combination of sender, reply-to, and subject. The Gmail web client uses internal thread identifiers to track emails sent from the web client more accurately. Have you thought about sending from different email addresses? With Gmail, for example, [email protected] is the same as [email protected]. Anything after + is stripped and ignored for the sake of mail routing, but I don't think it's ignored when computing thread membership. I'm not sure if this addressing rule is Gmail-specific or if it's part of the standard, though.