Headers for email notifications so that Gmail users can filter on tags?

Sure. The headers Discourse currently sets look like this (from an actual notification from this thread):

List-Unsubscribe: <https://meta.discourse.org/email/unsubscribe/efed8ca1777379c660afc031464b98eb4e6fa2323a71fa12fa2269eeca5b0905>                
X-Discourse-Post-Id: 1216779                                                                                                   
X-Discourse-Topic-Id: 249982                                                                                                   
X-Auto-Response-Suppress: All                                                                                                  
Auto-Submitted: auto-generated                                                                                                 
Precedence: list                                                                                                               
List-ID: Discourse Meta | feature <feature.meta.discourse.org>                                                                 
List-Archive: https://meta.discourse.org/t/headers-for-email-notifications-so-that-gmail-users-can-filter-on-tags/249982       
Feedback-ID: meta:user_replied:discoursemail   

If it weren’t for Gmail, adding something like:

X-Discourse-Tags: some-tag, another-tag

See Customs email headers and/or subjects tags - #6 by mattdm — if the email custom headers setting were passed through template expansion so X-Discourse-Tags: %{optional_tags} worked, this part would work already.

And, for procmail and other old-school email client users, this would be sufficient. Unfortunately, for whatever inscrutable Google reasons, Gmail can’t filter on arbitrary tags, and is (as far as I know) limited to To:, From:, Cc: and … fortunately at least, List-ID. Since that’s the 800-lb gorilla, to accommodate those users, setting List-ID by tag instead of category (or, in combination?) is the best I can think of.

However, RFC 2919 says that only one List-ID is permitted per message. So that leaves::

  1. Pick one tag arbitrarily[1]
  2. Generate something including all tags, like List-ID: firsttag_secondtag.discourse.example.org and let users figure that out. [2]
  3. Generate multiple emails per notification, one for each tag and differing only in this header[3]
  4. Leave List-ID referring to category, and instead use the CC idea… [4]

I don’t really love any of those. So as a first pass, X-Discourse-Tags: would at least cover the non-gmail users. (Which is probably a pretty good overlap with web-resistant users, so I think worth doing to see how far that gets us.)


  1. confusing! ↩︎

  2. not great ↩︎

  3. also not great ↩︎

  4. Pretty kludgy. Just adding Cc: %{optional_tags}[4] wouldn’t do it, because it’d need to be expanded so each tag corresponded to a real (black hole) email address. ↩︎

3 Likes