Using K9 and Stunnel to Filter Spam from Gmail
Updated July 28, 2007
K9 is my favorite spam filtering software, but it alone won't work with Gmail. I'm praying that one day there will be a version of K9 that will automatically handle SSL, but until then you can install Stunnel and configure it to work with K9. This will allow K9 to access SSL accounts like Gmail. It's a bit complicated, but just follow the steps.
(Note: This tutorial is for Windows XP, but you can probably figure out how to adapt these instructions for your operating system.)
- Download the latest version of Stunnel from the Windows installer page, http://www.stunnel.org/download/binaries.html.The Windows installer page is a bit confusing, but just look on the list for the most recent version of the stunnel installation program (ending in .exe not .asc). It is usually at the top of the list. For example, as of the writing of this tutorial (Nov. 26, 2006), the current file is stunnel-4.16-installer.exe (Aug. 31, 2006). Save this program to wherever you prefer to save downloaded programs (e.g. My Documents, My Downloads, Desktop, etc.)
- Run the Stunnel installation file to install the program on your computer.
- Scroll to the bottom of the Windows installer page, http://www.stunnel.org/download/binaries.html, and look for the OpenSSL Libraries section. In that section you will find libss132.dll and libeay32.dll. Save these files in your C:\WINDOWS\system\ directory.
- Go to
http://www.stunnel.org/pem/ to create a security certificate if you
can't or don't know how to do it on your own computer.
- Copy all of the code from -----BEGIN RSA PRIVATE KEY----- to -----END CERTIFICATE----- (including the -----BEGIN and CERTIFICATE----- tags)
- Paste it into Notepad.
- Save the file as stunnel.pem in your C:\Program Files\stunnel directory.
- Now you need to configure Stunnel. It's a little scary for anyone
who doesn't have much computer experience, but just relax and follow the
- Click on the edit shortcut on your Start Menu: Start > All Programs > stunnel > Edit stunnel.conf
- Find the line that contains
;client = yes
and delete the semicolon so it is just
client = yes
- Copy the following code and paste it above the line that starts with
accept = 127.0.0.1:11010
connect = pop.gmail.com:995
delay = yes
- Save the file and close it.
- Now, install the Stunnel service. This will allow the program to run
as a service in Windows. You can do this from the Start Menu.
Start > All Programs > stunnel > Service Install
- Now you need to run the service. Again, you can do this from your
Start > All Programs > stunnel > Service Start
- Go to http://keir.net/k9.html and download the installer for the latest version of K9 program and install the program.
- Run the K9 program.
- Click on the Advanced tab.
- In the POP3 Server box, check the "Enable this account" checkbox.
- Configure K9 to check your email account.
Account Name: your gmail email address
Server Name/IP: 127.0.0.1
User: your gmail email address
Password: your gmail password
- Click on the Configuration tab.
- Make sure "Listen on" is set to 9999. If not, set it to 9999.
- Make sure "Minimize to system tray icon" and "Minimize on startup" are checked. If they aren't, click on the checkbox to check them.
- Create a shortcut to the K9 program and put it in your Startup folder,
so the program will automatically start when you start Windows.
Start > All Programs > Start Up
- Setup your email client (Outlook, Thunderbird, Eudora, etc.).
- Install your email client, if you haven't already.
- Setup your email accounts (read your help files to find out how to do
this with your particular email program)
Incoming mail server (POP3): 127.0.0.1
Outgoing mail server (SMTP: smtp.gmail.com
User Name: email@example.com (replace "firstname.lastname@example.org" with your gmail email address")
Password: your gmail password
Server Port Numbers Incoming server (POP3): 9999 (DOES NOT require SSL / encrypted connection)
Server Port Numbers Outgoing server (SMTP): 465 (DOES require SSL / encrypted connection)
- Now test your account settings by sending an email from gmail account to yourself. (Note: sometimes if you send a message to yourself from your gmail account to your gmail account, it won't download to your email client ... strange, so try sending an email to your gmail account from another email address.)
Thanks to http://www.buckeyeplanet.com/forum/archive/index.php/t-18702.html for helping me figure this out.
See other Kristen's Guide topics in this category.