Message FiltersFrom MozillaZine Knowledge Base(Difference between revisions)
Revision as of 02:14, 21 August 2009Message filters are useful if you routinely want to perform certain actions on messages, according to criteria that you've specified. For instance, you can have incoming mail automatically sorted into different folders, with certain messages labelled, marked as Junk, or even deleted. Filters can be applied automatically to incoming mail, or you can run them manually when desired.
Creating filtersThis tutorial has clear, step-by-step instructions (with screenshots) for how to set up message filters in Thunderbird. You can also create a new filter from any message by right-clicking on the hyperlinked email address of the sender, where it appears above the message pane, and choosing "Create Filter From Message...." Important: filters must be set up on a per-account basis, and they likewise operate on a per-account basis. There is not currently any option to create "global filters" that will operate on all accounts 'except in the case of multiple POP accounts using the Global Inbox. In this case, you can create filters for Local Folders that will be applied automatically to incoming mail for all those accounts. Running filtersFilters that are enabled will be run automatically, in the order in which they are listed in the "Message Filters" dialog ("Tools -> Message Filters..."). Note that if you set up a filter to move an incoming message to a specified folder, subsequent filters will not be automatically applied to that message once it has been moved from the Inbox. There is currently no option to have filters be applied automatically to outgoing mail. To run filters manually on the currently opened folder, select "Tools -> Run Filters on Folder". To manually run only some of your filters rather than all of them, go to "Tools -> Message Filters...", select the filters you want to run, and click the "Run Now" button. Filtering the message bodyYou can filter based on the contents of the message body if you select "Body". If you have a message with both a plain text and a HTML version of the message body it searches both copies. This works for both local and remote (IMAP) folders. In Thunderbird 1.5 filtering the message body may not work if you have enabled quarantining individual incoming messages. [1] You used to be able to search the entire message (including all headers and the attachments) if you selected "Body" though for IMAP accounts you sometimes had to add it to the list box using "customize". Eventually that stopped working for IMAP and the developers explanation for why it was too hard to do ignored the issue of why it used to work for so many versions. Its not clear exactly when they changed it but in Thunderbird 2.0.0.17, Eudora 8 b4 and alpha 3 builds of Shredder (Thunderbird 3.0) you can search the "Body" in either a local or remote folder, but they have redefined it to mean just the message body. If Body isn't listed and adding it using "customize" doesn't seem to work add it to mailnews.customHeaders using the Config editor. Filtering based on TagsThunderbird doesn't have explicit support for filtering by tags but you can select Custom Headers from the leftmost list box while editing the filter rule and add support for X-Mozilla-Keys, and then test whether it "contains" that tag. Thunderbird uses that header to store tags. For example, X-Mozilla-Keys: forum fyi indicates the message has the forum and fyi tags. IMAP accounts store tags using message attributes instead, so its not possible to do that with messages stored in remote folders. If you copy the message to a local folder it currently doesn't add a X-Mozilla-Keys header with the tags, though it will add a empty X-Mozilla-Keys header when you compact it. [2] SpamWhile you can create message filters to test for Spam thats re-inventing the wheel. Its more efficient to use the junk mail controls . This article explains how to tweak the the junk mail controls to make them learn faster. You could also run other tools such as SpamAssassin or SpamPal that add headers to describe its analysis of the message and some sort of spam score that you can test. For example, SpamPal adds a X-SpamPal: PASS header if the message isn't spam. You could test that yourself, or configure the junk mail controls to trust SpamAssassin or SpamPal and have it test it instead. When you check for new mail message filters are run before the junk mail controls. There is no way to change that order. Testing whether a message is marked as junkThe message filters don't support testing whether a message is marked as junk. The information seems to be stored in the index file, not one of the two MozillaStatus headers. However, if you configured the junk mail controls to trust either SpamAssasson or SpamPal you could look in the SpamAssassin.sfd or SpamPal.sfd file in the isp directory in your Thunderbird program directory and figure out what it tested in order to mark the message as junk, and test the same thing. For example, the following line in SpamAssassin.sfd condition="OR (\"X-Spam-Status\",begins with,Yes) OR (\"X-Spam-Flag\",begins with,YES) OR (subject,begins with,***SPAM***)" means that SpamAssassin normally tests whether the X-Spam-Status or X-Spam-Flag header begins with Yes or the subject begins with ***SPAM***. Account specific filtersEach account has its own set of message filters, but they normally have no concept of accounts. You can create account specific message filters by checking the value of the X-Account-Key header. Use View -> Message Source and find the header, noting what its set to. For example, X-Account-Key: account10. Then create a message filter and scroll the leftmost list box (it defaults to Subject) down to Customize. Enter X-Account-key as the new message header, and press OK. Select X-Account-Key in that list box and test whether "X-Account-Key" "is" "account10" (replace account10 with the value your account uses) and select in "Perform these actions" what it should do. If the filter doesn't work see if Thunderbird changed the header it tests to Subject behind your back. Sometimes you run into a temporary glitch after adding a customized header. If that happens, exit Thunderbird, restart it , and edit the message filter to use X-Account-Key. Troubleshooting
If you have never written a message filter before and can't figure out what is wrong, try starting smaller and working your way up. For example, you might have written a filter to move certain new messages to a different folder and it doesn't seem to do anything. Modify the message filter to make it add a star to all new messages. That is something harmless you can see and easily undo manually. If that works then modify it to add the star only for those messages that you want to move to a folder. If that works then modify it to move the messages instead of adding a star. The reason for doing this is by starting small its easier to catch and debug common errors, or identify if there is something wrong with that account that prevents any message filter from working etc. You could create a message filter that adds a star to all messages by testing whether the "Subject" "isn't" "~!@#$%^&*()_+i" (or some other extremely unlikely string) and selecting "Add Star" in the actions list box. Test it using "Tools -> Run Filters on Folder". If no matter what you do it doesn't work, try replacing the contents of the "msgFilterRules.dat" file for your account in the profile as follows. If that doesn't work you probably choose the wrong account directory. version="8" logging="yes" name="Apply a star to all messages" enabled="yes" type="1" action="Mark flagged" condition="OR (subject,isn't,\"~!@#$%^&*()_+i\")" AlternativesThe Mail Classifier extension attempts to classify and move messages to other folders based on learning what messages you move, and to where. If you have a IMAP account your email provider may support server side filters. Thats a combination of message filters and junk mail filters that are run automatically by the server whenever it receives a message for your mailbox. Some may also provide the option to create custom scripts using the Sieve mail filtering language. There is a Sieve extension that lets you manage the Sieve scripts without having to use a browser. Unfortunately server side filters aren't available in free IMAP accounts provided by Gmail, GMX, or AIM. Some alternatives to the junk mail controls provide powerful filtering capabilities but they typically don't support the commands needed to manage messages. Other information
See also
External links
Thunderbird 3 only
Folder classification
. |
![]() |