Mini Media Mac
mini Spam Filter
How does this tutorial qualify as an application of the Mac mini in "home media?" Is email media? Media is a simply a means of mass communication, such as television, movies, radio, television and, I think, email. And the ways in which spammers distribute this unwanted intrusion into your inbox, the term "mass communication" certainly applies. If anything, I think this tutorial is more "media" than "Mac mini" since you could really use just about any Mac OS X 10.2 compatible Mac that you can connect to a constant internet connection. I used to use an old Beige G3, now I use a Dual USB iBook. But, of course, it will work better on a faster machine like a Mac mini.
This tutorial will explain how you can set up a Mac mini or spare Mac OS X 10.2 compatible Mac to be a 24-hour spam filtering drone. The process utilizes Apple's Mail application and IMAP email instead of POP. IMAP keeps email on the email server and lets you browse it much the way you browse web pages online. We will be using C-Command's SpamSieve, which will make it so that the drone Mac (or SpamSieve Mac as we will be calling it) will move suspected spam from the Inbox on the mailserver to a Spam folder also on that server. Because of the way IMAP works, both the SpamSieve Mac and your regular work-a-day Mac (we'll call it the "Spam Free Mac") see the same emails the same exact way; any mail moved on one Mac will be seen as moved on the other on the next check for email. This will make it seem like you have SpamSieve secretly running on any computer from which you access your IMAP mail account and it won't amount to another process taxing your Spam Free Mac.
It will take some time for SpamSieve to learn exactly what you consider spam. I will give you two AppleScripts (written for me by Michael Tsai from C-Command) that will give you a method of training the SpamSieve Mac remotely.
Here's what you'll need to get started:
- an IMAP email account (a .Mac account qualifies but is not the only option--check with your ISP or web host to see if your mailserver has IMAP capabilities)
- SpamSieve Mac: a Mac mini or other Mac (at least Mac OS X 10.2 compatible) that can be left on and connected to the internet
- Spam Free Mac: another Mac on which you will enjoy the freedom from spam that the previous Mac provides
- a constant (most likely broadband, but doesn't need to be) internet connection for the SpamSieve Mac
- Mail (included with Mac OS X)
- C-Command SpamSieve (bargain priced at USD$25)
- Spam Assassin (optional, but sweet)
Step 1: Set Up IMAP

First, you'll need to set up your IMAP account in Mail on both Macs as per your internet provider's
instructions. If you're like everybody, you probably have several email accounts, and I'd be surprised if most of them weren't available as IMAP. Once you set them all up on your SpamSieve Mac and on the Spam Free Mac, we should be able to rid them all of spam. After the IMAP accounts are established on both Macs, make sure you click on the checkbox next to "Automatically synchronize changed mailboxes" in each account's Advanced tab as seen at right.
If you already have all your email accounts set up in Mail as POP, it's not that big a hassle. MacWorld actually has an excellent article on IMAP and how to switch over.
Now that you are all set up on IMAP email accounts, choose one email account to be the main one. This should be the one with the largest quota. Since email on IMAP accounts is actually kept on the mailserver, some ISPs impose a quota or, more accurately, a cap on how much mail you can keep on your IMAP account at one time. Choose the IMAP account with the largest quota to be your main account.
On the main IMAP account, create 3 new mailboxes on within Mail on either the SpamSieve Mac or the Spam Free Mac. Name one "Spam"--this is where SpamSieve will drop the spam it catches. Name the second one "AddToSpam"--this one will be used by you to tell SpamSieve "you missed a spot." Finally, name the third one "AddToGood"--this will also be used to inform SpamSieve of an error...more on this later.
You will only need to set these folders up from one of your Macs; the others will automatically see these same folders through the magic of IMAP.
Step 2: Set up the SpamSieve Mac
There are a few caveats about this system:
|
Next, you'll install SpamSieve on the SpamSieve Mac by following the installation guide provided with the software, and configure it to dump caught spam in the Spam mailbox we just set up. You should also turn off Junk Mail filtering on the SpamSieve Mac.
So already we have SpamSieve working away on the SpamSieve Mac, removing spam from the Inbox so that your Spam Free Mac won't see it unless you really want to and intentionally go looking for it.
With respect to notification, I recommend turning Mail's New Mail sound off in the General section of its Preferences on the SpamSieve Mac. If you're using the SpamSieve Mac for media serving or any other use where periodic beeps and dings from incoming email are unwelcome, you can set SpamSieve's own Notification Preferences to play no sound, otherwise, choose a sound from that window to alert you to new good Mail. The Spam Free Mac can continue to use Mail's New Mail notification.
In Mac OS X's System Preferences, put both Mail and SpamSieve in the SpamSieve Mac's Login Items for the account you have used to set it up, set the Login Options to Automatically log in as the SpamSieve Mac's account and, in the Energy Saver Preferences, set it to automatically restart after power failure under the Options tab. Now if you're out on the road enjoying spam-free email at the local coffee shop, a momentary power failure back at home isn't going to force you to abandon your 6-shot Venti Sugar Free Vanilla Skim Extra Caramel Machiatto to come home and restart the SpamSieve Mac and launch the spam filter system again.
Step 3: Remote Training of SpamSieve
Remember the "AddToSpam" and "AddToGood" folders we set up on the IMAP mail server? We're going to use them to train SpamSieve from wherever you access your email.
First, we'll set up this system so that whenever you see spam in your Inbox on the Spam Free Mac, you can drag it to the AddToSpam folder. The next time you get mail, this will trigger the SpamSieve Mac to look in the AddToSpam folder and it will analyze the email in that folder and learn to recognize mail like that as spam.
Here's how; on the SpamSieve Mac, open your Script Editor and paste in this code:
on perform_mail_action(info)
tell application "Mail"
set theMailbox to mailbox "AddToSpam" of account "MyAccountName"
repeat with theMessage in messages of theMailbox
set theSource to theMessage's source
tell application "SpamSieve" to add spam message theSource
set theMessage's mailbox to mailbox "Spam" of account "MyAccountName"
end repeat
end tell
end perform_mail_action
You'll need to replace "MyAccountName" with the name of the main IMAP account your set up in Mail (leave the quotes, just change the name). Save it as an application named "RemoteSpamTraining" somewhere on your Mac ...someplace nice where you can find it but won't look at it sideways in a few months wondering what it was and toss it out.
Next, create a new rule in Mail on the SpamSieve Mac like what you see below:
Once you've clicked OK to this, drag it to the top of the list of Rules; we want this to be the second thing Mail does when it checks mail. "Second thing?" you ask. "Then why did we drag it to the top?" Patience--we're about to add another script that shall be the first thing Mail does when it checks mail.
You're going to need to make another AppleScript application on the SpamSieve Mac. This one will allow you to train SpamSieve to more rarely "return false positives" (translation: falsely accuse good emails). Create another application in the Script Editor with the following code (again, plug in your main IMAP account name where the code says "MyAccountName" but keep the quotes). Save it right next to the AddToSpam script if you like:
on perform_mail_action(info)
tell application "Mail"
set theMailbox to mailbox "AddToGood" of account "MyAccountName"
repeat with theMessage in messages of theMailbox
set theSource to theMessage's source
tell application "SpamSieve" to add good message theSource
set theMessage's mailbox to mailbox "Inbox" of account "MyAccountName"
end repeat
end tell
end perform_mail_action
***Note: if you have trouble with this Applescript under Mac OS X 10.5 Leopard, change "Inbox" to "INBOX" — Thanks Adam!
Now set up another rule in Mail on the SpamSieve Mac like the other one, only call it "Remote Good Mail Training" and point it to your RemoteGoodMailTraining script you just made. Drag it to the top of the Rules list right above Remote Spam Training. I guess it could go under, but we want the process to stress the availability and reading of good email since that is the good life we're after.
So here's how this system works: You go about your day on your Spam Free Mac, checking email as you like to and, for the most part, you will notice that SpamSieve does a great job at filtering spam once you have gone through the initial training methods outlined in C-Command's installation guide. But, every so often, some spam sneaks through. What do you do? Just drag it to the "AddToSpam" folder. The next time the SpamSieve Mac gets new email, it will also check inside the AddToSpam folder and automatically train itself to see mail like this as being spammy. It will then move it to the Spam folder. Uh-oh! You happened to look in the Spam folder and there's an email in there that isn't spam! What do you do? Just drag it to the "AddToGood" folder. The next time the SpamSieve Mac gets a new email, it will check the AddToGood folder as part of the Rules process and train itself to go a bit easier on the kind of mail it finds in that folder. Then it will escort that email to the Inbox of the main IMAP account. (NOTE: it will move the email to the Inbox of the main IMAP account regardless of whether or not that was the account for which that email was originally intended. Once it has arrived safely in that account, you can simply drag it to the Inbox of any account you wish.) It's simple:
|
Extra credit bonus for SpamAssassin users
Does the mailserver of your main IMAP account have SpamAssassin installed? If it does you can take your spam filtering to another level.
You can use your Spam folder to train SpamAssassin with the spam that SpamSieve caught. This will eventually reduce the amount of spam that makes it through for SpamSieve to check--it will be blocked at the front door. All you have to do is make another AppleScript application like the one below (confer with your mailserver administrator for the exact server name, password and path for your particular mail account and Spam folder... leave the quotes).
tell application "Terminal"
activate
do script "ssh your.mailserver.com" in window 1
delay 20
do script "password" in window 1
delay 6
do script "sa-learn --mbox --spam ../../path/to/your/online/folder/.imap/Spam" in window 1
end tell
Just allow your spam to collect in the Spam folder and then run this script every week. After it's done, delete the contents of your Spam folder and enjoy life.
Conclusion
So now you should no longer be in fear of checking your email. What you might not realize is that, though SpamSieve is a Mac-only application, it doesn't keep you from checking your SpamSieve filtered IMAP email accounts on Windows, Linux, Palm OS, or even your cell phone. As long as you can set up IMAP email accounts and move the occasional spam message from the Inbox to the AddToSpam folder, this system will work to keep you spam-free any which where you go.
Wow, this has been a long tutorial with a lot of AppleScripts but, once you've got all this in place, it is really simple and satisfying to use. Ah, the spam free life... after a while you'll wonder what everyone else is complaining about--Spam? What's that?
All personal comments should be sent to the author. All other discussion should be done in the Forums
[ Back to Mini Media Mac | Sections Index ]





