BMO/UserGuide/Filtering Bugzilla Email in GMail

From MozillaWiki
Jump to: navigation, search

Gmail's filtering capabilities are largely limited to filtering on the message body, rendering the large number of Bugzilla "X-Headers" unavailable for filtering. To work around this, (BMO) has a preference to include the X-Headers as hidden text within the message body.

While it's possible to generate filters using email's body (for example using the Product/Component: XXXXXX :: text), there are limitations to this approach: false positive matches are possible, and BMO does not guarantee that the human-readable portion of emails it generates will remain constant. In short, you may end up with broken filters.

Note: if you are using filters to simply discard mail, as opposed to classifying it, then Bugzilla has recently acquired more capabilities to do this on the server side. See the Bugmail Filtering tab in your preferences.

Note: gmail is unable to filter encrypted bugmail.


  1. Enable HTML Email
  2. Enable X-Headers in the BugMail body
  3. View source to view the message headers
    • If you use the Gmail web interface, select "Show original" from the message's action menu (next to the "Reply" button)
  4. Create a filter in the format "X-Bugzilla-header: value"
    • See the examples below
    • You can create the filters by either
      • Entering the text of the examples into the Gmail search box to have the filter prepopulated with the field:value data from the examples
      • Entering the text of the examples into the "Has the words" field of the filter

X-Headers Example

Here's a collection of X-Headers from a random email.

X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Classification: Components
X-Bugzilla-ID: 997908
X-Bugzilla-Product: Core
X-Bugzilla-Component: XPCOM
X-Bugzilla-Version: 30 Branch
X-Bugzilla-Keywords: crash
X-Bugzilla-Keywords: leave-open
X-Bugzilla-Keywords: topcrash-mac
X-Bugzilla-Severity: critical
X-Bugzilla-Status: REOPENED
X-Bugzilla-Priority: --
X-Bugzilla-Target-Milestone: mozilla31
X-Bugzilla-OS: Mac OS X
X-Bugzilla-Changed-Fields: Comment Created
X-Bugzilla-Changed-Field-Names: comment


  • If a field has multiple values, it will appear multiple times. The above example has 3 keywords, resulting in 3 individual X-Bugzilla-Keywords fields. This is different from the "real" X-Headers where all values will be groups under a single header.
  • There may be additional headers depending on the Bug's status and your relationship with it.

Example Filters

All filters take the form "X-Bugzilla-header: value"

We need to identify the sender as BMO using the from address, then search for the relevant header and value.

  • Filtering by product
    • "X-Bugzilla-Product: Firefox"
  • Filtering by component
    • "X-Bugzilla-Product: Core" "X-Bugzilla-Component: XPCOM"
  • Filtering by reason or by watch reason
    • "X-Bugzilla-Reason: CC"
    • "X-Bugzilla-Watch-Reason: QAContact"
    • Possible reasons are: AssignedTo, CC, Reporter, QAContact, GlobalWatcher, Component-Watcher
  • Filtering for Bugs you mentor
    • "X-Bugzilla-Mentors:"

Use case: catchall Bugmail folder

I have a tree of Bugzilla folders. The parent of the tree is a "catchall" which gets all mail from Bugzilla that doesn't match one of my other Bugzilla filters. The rest of the folders under it are either product or component specific, or looking for bugs assigned to me or reports sent from Bugzilla, etc. The problem is that Gmail has no concept of "stop running filters once this matches". ALL of your filters will be run. Period. This means that without any special consideration, a filter which matches a specific component will add the label for that component, and then your catchall filter for anything from Bugzilla will also add the catchall Bugzilla label, so you'll have it in both places. However, GMail does run the filters in a specific order, which gives us somewhere to start. They get run from top to bottom, with the filters at the end getting run last.

So let's trap for a product:

  • from:( "X-Bugzilla-Product: Firefox"
    • Skip Inbox
    • Apply label "BugMail/Firefox"
    • Never send it to Spam

I do "Never send it to Spam" here because I have gotten bugmail in my spam folder on GMail after I started getting my bugmail there.

The "Skip Inbox" is important for this trick to work. You were probably doing it anyway, but I'll just point that out. It's sort of a misnomer, because everything starts out in the Inbox anyway, what they really mean is "remove it from the inbox". Now our catchall:

  • from:( label:inbox
    • Skip Inbox
    • Apply label "BugMail"
    • Never send it to Spam

In our filter for the catchall, we are specifically looking only at messages that are still in the inbox. If one of our other bugmail filters already got it, it won't be, because they did "Skip Inbox". For this to work, the catchall filter has to be last. Every time you add a new Bugmail-related filter, it will put it at the end. Google does not provide a way to re-arrange your filter order. However, if you make a change to a filter, it will move it to the end. So every time you add a Bugmail-related filter, you will also need to edit the catchall filter to move it back to the end again. I usually end up editing it twice. In the first edit I remove the "Never send to spam" checkbox. This moves it to the end of the filter list. Then I edit it again to check the box again to put it back how it was. If you hit the "Update" button without actually changing anything, it won't move it to the end.

You can also do more massive re-arranging of filter order by going into Labs in the settings and enabling the filter import/export. Then you can export your filters, re-arrange them in the file, and re-import them. This is more work in my opinion, and if you only need to move one it's easier to just edit it. But if you're wanting to do lots of rearranging it'll save a lot of thinking.