Filter/search (possibly absent) headers in Mail.app

I’ve been trying to get Mail v12.4 (Mojave) to extract mailing list/newsletter mail out of my pile-up box so that I can deal with it more effectively, in the fashion of Sanebox’s “@SaneNews” filter, which so far has provided the only remedy for use with my iCloud mail account. If it’s anything like Exim’s “personal” test, and much of the mail does seem to be fairly predictable in that regard, then I really need to filter in particular on the List-* (List-Unsubscribe, List-Id, etc) headers. Trouble is, I can’t make it work. If I set up the rule with, say, “list-id contains .” or “list-unsubscribe contains mailto” (first adding the list-id and list-unsubscribe headers to the list of custom headers) to try and get all mail using those headers, I still capture a lot of non-list mail without the headers present. And I don’t see any way to filter on any but a few basic headers in the search filter box in the toolbar at all.

I don’t suppose anybody else just happens to be facing a problem like this? I’m about ready to give up and use a separate tool to fetch all my IMAP mail to a local folder and filter it using other tools and then sync back the changes, but I’d prefer to keep all my local filtering logic in Mail.app if possible because that would make it easier to manage and I wouldn’t have to fiddle with background scheduled command-line tools. Particularly since this is expected to be a one-time setup. Sidenote: iCloud server-side filtering is just desperately sad (but at least List-Id filtering is now possible). Notwithstanding the web interface making it generally clunky to manage, it does not even begin to match the modest power of Mail.app.

TIA for suggestions.

I don’t do this myself, but I was intrigued after reading this yesterday, so I set up a quick rule. For me, looking for “any” of the mail header “List-Unsubscribe” “contains” “mailto” or “List-Unsubscribe” “contains” “http” seems to capture almost everything that I consider to be promotional (my rule sets the background to orange rather than move messages, which makes it pretty obvious if it works.) These messages also seem to coincide almost exactly with Mail’s notification at the top of the message that says “This message is from a mailing list”.

If in your case you are finding that this is capturing too many emails, then maybe a rule in the lister higher than this one that looks for “any” of “from” “contains” and then specific email addresses of senders that you don’t want filed this way, with the action being “stop evaluating rules”, might get you most of the way there.

I’m on Big Sur, by the way, but I have one machine on Mojave and I’ll see how this works there.

[edit] I just checked on Mojave, and the rule is working there as well.

1 Like

Thanks for testing! I’ll come back to this soon and see where I’m going wrong, but I’m glad to hear the actual conditions are working for you. IIRC I was getting mail in the newsletter folder where these headers were completely absent, so I think it must be the logic of my entire ruleset. I’ll clean everything out and redo them.

Yes, the banner in Mail that lets you unsubscribe appears where there’s a mailto in the List-Unsubscribe header. Sadly, it doesn’t always work because some mailing list software wants the request to originate from the subscribed address and Mail doesn’t let you choose which one to use, if you have multiple addresses or receive mail at a forwarding address.

Cheers.

OK, so it turns out this was my fault. The rules did work, but I was trying to go in the inverse direction, using “does not contain” to shuffle genuine mail back into my Inbox. I’d dispute the logical “does not contain” operator also meaning “or is completely absent”, but whatever–it now works. If you apply your rules to an existing folder, best to capture mail matching than not matching; you can shuffle the mail later to get the intended effect. I now have two folders, which cleanly separate much of the nonsense from the important stuff (with, as it turns out, a few exceptions where mail is getting sent through mass-mail platforms that insert these headers even though they’re actually personal mail).

Ta for the help!

3 Likes