How to export and import message filters of Thunderbird

I have several installation of Thunderbird under Linux to check/send emails using IMAP email servers. I use filters extensively to manage my emails. How to export and import message filters of Thunderbird so that I can synchronize the rules on several installations?

About message filters in Thunderbird (More at

Filters are account specific, there is no support for global filters.
The closest thing to a global filter would be to configure several POP
accounts to use a Global Inbox. In that case, you could create filters
for the Local Folders pseudo account that would be applied
automatically to incoming mail for those accounts.

Where the filter settings are stored?

The file that stores your filter settings is called “msgFilterRules.dat”. Each account will have its own “msgFilterRules.dat” file, stored in the “Local Directory” for the account in your profile. The Local Directory is specified at the bottom of Tools -> Account Settings -> Server Settings, right by the Browse button. The filters for Local Folders are stored in the MailLocal Folders directory in the profile.

How to backup/duplicate the filters?

If you want to duplicate an accounts filters in another account you don’t need to create them again. Exit Thunderbird and copy the “msgFilterRules.dat” file instead. If the account is in another profile and it uses custom headers you will also need to copy the mailnews.customHeaders setting from prefs.js.

Remember to close Thunderbird before manually change these msgfilterRules.dat files. Otherwise, Thunderbird will overwrite your changes.

To quickly find all your filter setting files on Linux, run

find ~/.thunderbird/ -name msgFilterRules.dat

The msgFilterrules.dat is just plain text file. Edit it as you needed—usually just the directory paths for duplicating an account’s filter to another account.

Like you, I want to have one and only one mail filter set. This can be done, at least on Linux.

Go to the directory, /home/[username]/.thunderbird/[random].default/

sudo find / -iname “msgFilterRules.dat”

will show you all the filters as described by others. Pick whichever one you want to be the main one. I chose ./Mail/Local Folders/msgFilterRules.dat, which is the rule in the Local Folders directory that I don’t otherwise use. Copy the one you want every account to use into this directory.

Go to each mail directory and enter the command:

ln -bsv ../../Mail/Local Folders/msgFilterRules.dat msgFilterRules.dat

This will backup the previous filter file, and create a soft link to the file in ./Mail/Local Folders. [Obviously you’ll have to alter this if you want a different filter file to be your primary.]

In effect, every mail account will follow the softlink and load the same ruleset.

What I haven’t checked yet is what happens if you choose to edit your filters in Thunderbird. Presumably the link would be wiped out. But as long as you have a copy of the final version of your filters, you can restore them easily enough.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.


  1. I have a problem with TB (imap) in Linux Mint 17.1. There must have been a crash a few days ago and when I started TB it had nothing. I have managed to load everything except the message filters and the calendar. Both of these are empty.

    How can i recover these features without having to create them from scratch?
    Thank you

  2. Thank you! I’ve reinstalled Thunderbird so many times and resetting the filters can be annoying. I kept forgetting how to copy the filters, but thanks to your guide I sorted it.

Leave a Reply

Your email address will not be published. Required fields are marked *