Spam filtering with Kmail

SPAM. It's a dreadful word that causes many a computer user to yank out their hair and wish their service provider would do a better job of keeping SPAM out of your inbox. But that is not going to happen over night. So...it is up to the end user to make sure they have extra means of SPAM prevention rolled into their email clients.
Most email clients contain some sort of SPAM prevention. On the Linux operating system you can employ such tools as Bogofilter or Spamassassin. Either of these tools are great for stopping SPAM - but what about using them with your favorite email client? With some Linux email clients you have to add extra applications in order to have one of these SPAM filters doing their job with your client. Some clients, however, have built-in tools to save you a little work. KMail belongs to the latter category. So long as you have either/or Bogofilter or Spamassassin installed, you are one step closer to having solid SPAM filtering.
In this article you will learn how to set up reliable SPAM filtering in the KMail mail client.
Bogofilter and Spamassassin
KMail can use either Bogofilter or Spammassassin easily. Read up on either tool and decide which application you want to use. I have had good luck with both, but I do believe Bogofilter is easier to set up. And since KMail will automatically detect either, the choice is yours.
You can install either tool from within the Add/Remove Software utility by following these steps:
- Open Add/Remove Software utility.
- Search for either "bogofilter" or "spamassassin" (No quotes).
- Select either (or both) tools for installation.
- Click Apply to install.
That's it. Now you are ready to move on to KMail.
Kmail SPAM Wizard

When you have KMail set up and running click on the Tools menu and select the "Anti-SPAM Wizard" entry. When the Wizard opens the first thing it will do is detect which SPAM tools you have installed (see Figure 1).
Once the wizard has detected your SPAM tools, select the tool you want to use and click Next. For the purpose of this article I will select Bogofilter.
The next step in the wizard will ask you for two configurations:
- Mark detected SPAM as read: I prefer to unset this, because of the next configuration option.
- Which folder to relocate SPAM: By default KMail will move SPAM to the trash folder. I prefer to create a new SPAM folder in order to catch any false-positives.
By moving SPAM to a specific SPAM folder (and not the trash folder) and keeping SPAM unread, you are less likely to miss any email mistakenly marked as SPAM (false-positive).
The final window of the wizard gives you a report on what you have set up. In my case the wizard creates the following filters:
- Bogofilter Check
- Spam handling
- Classify as Spam
- Classify as NOT Spam
Click the Finish button and your KMail client is ready to learn. And learning is the key.
Help Bogofilter learn

Before Bogofilter can become a reliable SPAM filter, it has to learn what should be classified as SPAM and what should be classified as HAM. Here's how I like to do it. Allow plenty of email to collect in your inbox. As the mail comes in take all SPAM (that is not already marked and moved) and move it to the SPAM folder. Once you have cleared your Inbox of all SPAM, select all mail in that folder and then click the Ham button (see Figure 2).
Now, once you have collect a good amount of SPAM in your SPAM folder open that folder up, select all the SPAM, and click the SPAM button.
You may have to do this trick a few times before Bogofilter has been properly trained. You will know when Bogofilter has become accurate with your SPAM/HAM.
Final thoughts
It couldn't be much easier to catch and mark SPAM with KMail and Bogofilter. But if you find Bogofilter not as reliable as you would like, run the Wizard and try Spamassassin instead.


You said that Outlook isn’t your main email client, so which is your main one?
I think its thunderbird
It is Mozilla Thunderbird.
Awesome! This actually solved my problem… what a stupid bug.
If this is the same bug that I’ve encountered, there may be another fix: (1) hover over open Outlook item in Taskbar, cursor up to hover over Outlook window item, and right-click; (2) this should give you Restore / Move / Size / Minimize / Maximize — choose Move or Size; (3) use your cursor keys, going arbitrarily N/S/E/W, to try to move or size the Outlook window back into view. Basically, the app behaves as though it were open in a 0x0 window, or at a location that’s offscreen, and this will frequently work to resize and/or move the window. Don’t forget to close while resized/moved, so that Outlook remembers the size/position for next time.
THANK YOU Claude!!! I could get the main window to launch but could not get any other message window to show on the desktop. You are my hero!!!!
Solved my issue! 6 years later and this is still problem…
Fantastic. Thank you. Size did the trick.
This solved my Outlook problem, too. Thank you. :)
Thank you so much, this started happening to me today and was causing big problems. You are a life saver, I hope I can help you in some way some day.
You are a god – thank you!
thanks a lot…. work like charm.. :-)
Yah…thanks Claude. I’ve been having the same problem and tried all the suggestions…your solution was the answer. It had resized itself to a 0/0 box. Cheers
Excellent post. This had me baffled even trying to accurately describe the problem. This fixed it for me.
Thank you
Thanks a lot for the article. Don’t know why it happenend, don’t know how it got fixed, but it was really annoying and now it works :-)
Thanks a lot. I was facing this issue from past 3 week. I tried everything but no resolution. The issue was happening intermittently and mainly when I was changing the display of screen ( as i use 2 monitors). The only option i had was to do system restore. But thanks to you.
I’ve been tried to sole this problem for 12hours. Your comment about changing the display of screen helped me a lot!! Thanks!!
Thank you…don’t know why this happened but your instructions helped me fix it. Running Windows 10 and office pro 2007
Great tip! Thanks!
Worked for me, too – thank you!!!
It’s Worked for me, too
thank you very much!
I had a similar issue with Outlook 2013 on Windows 10 and this helped me to fix it. Thank you very much!
Thank you so much. Solved!
Considering you published this in 2012, incredible not been debugged by Microsoft.
Thank you again. M
This problem was faced by only one user logging to TS 2008 r2 using outlook 2010.The issue was resolved.
Thanks.
Great tip. Thank you!!!! If it helps, I had to use the Control Key and the arrow keys at the same time to bring my window back into view. Worked like a charm.
Thank you, this worked !!!!
Man, you are a fucking god. Thanks a lot, what an annoying bug!!
Awesome, this post solved the issue. Many thanks!