Severing independent email threads with KMail

I use KMail and it, like many other popular email clients, sorts messages into threads. It does this based on reference information embedded in the (usually hidden) headers of each message. Of course, sometimes those headers are off. Most commonly this happens because a sender uses a reply-to-all function to send a new message to an existing list of addresses—this new message has a completely different subject from the original (to which it's ostensibly replying), but the sorting at the receiver's email client still considers it part of the old thread because reply-to-all functions add headers referencing the original message, as well as others in the original thread.

Fortunately, KMail has the ability to remove those headers through manually applied filters. The bonus is that, once you do this, the corrected threading will propagate to other email clients—I use K-9 Mail (not related to KMail) on my phone, for example.

First, there are two email headers that are relevant, each serving a different purpose: In-Reply-To, which links to the previous email that the present one is a direct reply to, and References, which lists several emails that are considered part of the thread (according to reply-to-all). For a single arriving email that starts the new topic, removing both these headers is necessary to break the thread. However, a follow-up email on that new topic may well have the old thread's emails listed in its References (presumably because the sender didn't correct the headers of the first email). Thus, two filters are needed to do this right: one to remove References, which can be applied to the first and all subsequent emails on a new topic (ensuring they all live in a distinct thread, never associating with the prior thread), and one to remove In-Reply-To, which is applied only to the first email on a new topic. We don't want to apply that last one to the subsequent emails, or there will be no way to associate them to any thread at all!

Here's how to set these up in KMail:

  1. Open the Settings menu and select Configure Filters...
  2. Make a new filter: click the New button below the Available Filters list. Select it from the list, press the Rename button, and call the new filter “Remove References”.
  3. In the General tab, under Filter Criteria, ensure the filter is set to “Match all messages”.
  4. In the pull-down under Filter Actions, select Remove Header, and in the text box beside it, type “References”.
  5. We want to ensure that this filter is not triggered automatically, but must be explicitly invoked. Click the Advanced tab. Uncheck “Apply this filter to incoming messages”, “Apply this filter on manual filtering”, and “If this filter matches, stop processing here”. Check “Add this filter to the Apply Filter menu”.
  6. If you like, click the icon button to select an icon to use for this filter in the menu. I personally like “object-ungroup” from the Actions list (System icons).
  7. Create another filter and call it “Remove In-Reply-To”.
  8. In the General tab, make the filter to “Match all messages”, and set its action to Remove Header for “In-Reply-To”.
  9. In the Advanced tab, uncheck the checked setting as before, and check “Add this filter to the Apply Filter menu”.
  10. Select an icon (if you like). I use “node-break”.
  11. Click OK.

Now whenever you find yourself with an email that shouldn't be part of the thread it has appeared in, you can apply these filters to that message: right click the email and navigate to the Apply Filter submenu, or select the email and find it in the Message menu. If it's the first email on the new topic, apply both the Remove References and Remove In-Reply-To. If it's a subsequent email, apply just Remove References.


Comment to add? Send me a message: <brendon@quantumfurball.net>

← Previous | Next →