Junk Mail Controls
From MozillaZine Knowledge Base
This article applies to both Thunderbird and the Mozilla Suite. The Junk Mail Controls interface in the Mozilla Suite is slightly different from the Thunderbird interface, described below.
Activating the Junk Mail Controls
To start using the Junk Mail Controls in Thunderbird*:
Training the Junk Mail Controls
Junk processing must be well trained for it to work correctly. Training involves marking many messages as "junk" and many messages as "not junk". It is important to mark both types of messages, both good and bad, not just the ones that are junk.
Initially, incoming messages might not be accurately junked because you have not trained it enough.
After an initial training period
There are various ways that you can mark messages:
You don't need to keep the messages you have marked - marking stores the information it needs as tokens in the training.dat file. Training data for the Junk Mail Controls is stored in "training.dat" in your profile folder. You can view the Junk Mail Log by selecting "Junk Mail Log" in "Tools -> Junk Mail Controls -> Logging", and then use the mouse to 'grab' any corner and stretch it until it expands enough for you to see the log data.
Tweaking the Junk Mail Controls
mail.adaptivefilters.junk_threshold is the preference that determines at what "level" messages are classified as junk. It defaults to 90. Lowering this value will make it easier to recognize messages as spam, though it increases the risk that it will classify a legitimate message as spam. This might help get more messages marked; for example, messages that look like text but are actually clickable images. (Note however, adaptive processing does NOT examine images nor care about whether a message has an image - it is not part of the junk algorithm)
You can change the preference using Tools -> Options -> Advanced -> General -> Config Editor. Enter junk in the Filter field to show only the preferences that contain junk in their name, and then double-click on mail.adaptivefilters.junk_threshold, enter a value lower than the default 90 in the edit field and press the OK button. Many users report good results with values of 30 or lower.
JunQuilla is an add-on which can help you tweak junk processing and help you better understand how it is working. It provides a column that shows the odds that a message is spam, enhances the junk status column, and adds a Uncertain folder for messages requiring a users decision. It requires Thunderbird version 3 and newer.
Bayes Junk Tool can also be used to examine and modify the raw training data. Sometimes it helps to get rid of tokens that are just as likely to occur in spam and legitimate messages, especially if the training data file gets very large. The web site also has several sets of training data that you can import or merge with your existing training data.
Bayesian filters are useful, but they are not always the best tool. Sometimes checking whether the message was sent by somebody on a DNSBL list is more effective. See this article for how to integrate SpamPal and the junk mail controls, and control which messages are downloaded.
The FolderFlags extension can set various internal flags that Thunderbird uses to classify folders. If you set the "Junk" flag on a folder (other than the one spam is moved to) it won't scan that folder for spam.
The Delete Junk Context Menu extension adds "Delete Mail Marked as Junk" to a folders context menu. It can be configured to delete mail without moving it to using the Trash folder.
Any mention of "spam"
Thunderbird doesn't use or react to the word "spam" in its identification of junk mail, nor does Thunderbird put it in the subject.
If you see the "spam" in a subject or have a folder called "Spam", this is either due to your email provider or an add-on product (such as SpamPal). If it's due to your email provider, log into your webmail using a browser and browse its help to get more information. Your provider may support webmail commands to let you manage or disable whatever they're doing.
Use custom headers added by your email provider
Your email provider may run a spam filtering program on their mail server such as SpamAssassin, MailScanner, CRM114, SpamProbe, QSF or Bogofilter that analyzes each message and adds custom headers with information about its content. If they use SpamAssassin, see the next section for how to integrate it with Thunderbird's junk mail controls. Otherwise, use "View -> Message Source" and look for headers whose name begins with a 'X' and contain phrases such as Spam. They typically provide a spam score and/or keywords that you can test using message filters.
X-Spam-score: 1.5 X-Spam-hits: BAYES_60 1, HTML_IMAGE_ONLY_16 1.526, HTML_IMAGE_RATIO_08 0.001, HTML_MESSAGE 0.001, RCVD_IN_DNSWL_LOW -1, SPF_HELO_PASS -0.001, SPF_PASS -0.001, BAYES_USED global X-Spam-source: IP='22.214.171.124', Host='mail.anp.se', Country='SE', FromHeader='com', MailFrom='se'
You could test whether X-Spam-score "is greater than" a certain value, whether X-Spam-source "doesn't contain" Country='US' (the example was from Sweden) or test whether X-Spam-hits "contains" certain keywords (they're the name of a test that increased the spam score) that you notice that the junk mail controls has problems recognizing spam with those attributes. Not every email provider will provide as much customization as the example, but it should at least have some sort of spam score you can test.
Trusting SpamAssassin and SpamPal
Spammers sometimes use Bayesian poisoning to degrade spam filters that use Bayesian filtering. SpamPal uses DNS Blacklists and SpamAssassin uses several methods (it's best known for its extensive testing of message headers) to filter spam so that type of attack has little or no effect on them. Both of them add special headers to a message to indicate whether it's spam. SpamPal is only available for Windows, but the Wine Application Database rates it as platinum (i.e. install and run flawlessly on an out-of-the-box Wine installation)
Some email providers customize the headers added by SpamAssassin, or modify the subject prefix. This can cause the junk mail controls to ignore the information. "Trust header" is actually a standard message filter, stored in a isp subdirectory in the Thunderbird program directory. Thunderbird checks whether either X-Spam-Status: or X-Spam-Flag: begins with Yes, or the subject begins with ***SPAM***. If you run into this problem backup the SpamAssassin.sfd file and then change what it tests for using a text editor (not a word processor). There is also a SpamPal.sfd file.
Some users have reported that the trust SpamAssassin option sometimes ignores the junk mail headers in Thunderbird 2.x. It's not clear whether you can work around this bug by disabling the option and adding the appropriate message filter.
If you use SpamAssassin you might want to uncheck "enable adaptive junk mail controls for this account" in Tools -> Account Settings -> Junk Settings. That controls the Bayesian filter in the junk mail controls, which is what it uses to learn how to recognize junk. SpamAssassin is normally configured with a Bayesian filter that is more sophisticated, has more data to learn from (it learns from all of your email providers messages, not just your messages), and is probably tweaked by the same admin who tweaks the SpamAssassin filters. Having two Bayesian filters for the same account makes things unnecessarily complex. For example, it's not defined what's supposed to happen if you mark a message as not junk, and later on the adaptive junk mail controls notices (again) that SpamAssassin says it's spam.
You could probably edit the SpamAssassin.sfd file in the isp subdirectory in the Thunderbird program directory to make the junk mail controls think another spam filter such as SpamBayes is actually SpamAssassin. The first step would be to figure out what the spam filter modifies in the message in order to identify whether it's spam by looking at a messages source.
Thunderbird Junk mail controls do not support trusting SpamBayes. But the ThunderBayes add-on integrates SpamBayes with Thunderbird with a toolbar button to classify a message as "Spam" or "Ham", and a preferences page in the account settings.
The junk mail controls don't support trusting Spamato, possibly because the Spamato instructions recommend disabling the junk mail controls. There is a Spamato forum, some documentation on the different types of spam filters they support and a FAQ on sourceforge.net. Spamato does not store its information in the Thunderbird profile, it creates its own profile
One way to weed out image-based spam is to create a message filter and set it to match all of the following:
In "Perform these actions" add
This will mark the message as junk and move it to the Junk folder if the Content-Type header contains multipart/related and the sender wasn't in your address book. The message filters don't know how to recognize Content-Type headers, you will need to add it using the "customize..." option at the bottom of the leftmost list box. This method is rather heavy-handed. If your email provider runs a spam filter program such as SpamAssassin, it will typically do a much better job recognizing image spam.
Problems with junk processing
After classification filters
See Managing spam with “after classification” filters for how to use spam classification in a message filter.
Regular expressions - advanced
Neither the junk mail controls or the message filters support wild cards or regular expressions. There don't appear to be any extensions that add support for that. However, SpamPal (a mail classification program normally used for filtering spam) supports a RegExFilter Plugin that adds regular expression support based on Perl Regular Expressions. If you configure the junk mail controls to trust SpamPal you could use regular expressions to filter spam. 
There are many other SpamPal plugins available here. For example, you could extend white lists and black lists to apply to email addresses from any header, white list any message that contain words from a list of good words, filter on what web sites are mentioned, launch other programs (passing them information about the message as command line arguments) or run Ruby scripts. The main drawback is none of this is integrated into the junk mail controls - it just knows when SpamPal marks a message as spam.
Sender Policy Framework (SPF) is a method for verifying an email sender's domain name, to figure out whether an address is spoofed. The Sender Verification Extension makes use of SPF to verify the From address on emails, plus DNS black and white lists such as SURBL, Spamhaus, DNSWL, and Sender Score Certified to check the sender's reputation. When you open a message, the add-on adds a line at the top of message with the verification status of the sender. For example, "Reputable Sender", "This sender is a known malicious spammer or phisher. Discard this email", or "Sending domain does not support verification (address could be forged).". You have to actually read the message to get the warning (it is not meant to be used as a mail filter), and it's probably most useful as an alternative to Thunderbird's phishing protection (which most users disable due to its inability to learn and its many false positives).
Check the spam score of messages you sent
MailingCheck is a free Windows program that calculates the spam score of a message based on SpamAssassin rules. Its useful if you suspect that some of your recipients aren't getting your message due to it being treated as spam and you can't verify that by having them check in their junk mail folder. Port25 (copy and paste a message) , mail-tester (email them) and emailspamtest (copy and paste a message) are web sites that perform similar checks for a message.
You might want to also check if your mail server is black listed by checking it with a web site such as MXToolbox.
Junk filtering in newsgroups
See the webmail spam folder
A POP account is only aware of one folder stored on the POP server, the inbox. This is a limitation of the POP3 protocol. However, its possible for some POP3 servers to be configured to lie to the email client, and provide the contents of both the inbox and the spam folder used by webmail when the email client checks for new mail. This is totally transparent to the email client. Email providers that support this have a webmail settings to configure this.
IMAP accounts don't have this limitation. That can use the same folders as webmail.
Most add-ons to report spam seem to report it to little known organizations. The best seems to be the HabuL add-on that "Reports spam to the SpamCop, the FTC, FDA, SEC, ACMA and/or Knujon.com. It also allows you to put in your own custom addresses to report spam to such as your ISP or corporate abuse address."
If you are using a IMAP account some email providers let you specify (using webmail commands) that any messages in your junk folder should be used to help train a personal bayes database to recognize spam. This improves the spam filtering done by your email provider. Improved spam filtering with per-user bayes databases is one example.
Add-on to improve Thunderbird's junk processing
Add-ons interfacing to external services