![]() |
|
||
|
When I began developing SimbeyMail, I put a little bit of thought into spam
filtration. I even wrote a simplified Bayesian filter, but I didn't find writing
filters to be very exciting or rewarding. I realized I would have to spend a lot of
time tweaking filter variables and testing, and I decided there were other aspects to the
server that were more important. I have looked at open source spam filters to see about making them compatible, but I just haven't gotten around to it. I probably won't. However, SimbeyMail has an easy plug-in model for building spam filters, so if anyone would like to write a filter, then by all means! All you need to do is include SpamFilter.h in your project, implement the ISpamFilter interface, and expose a global GetSpamFilter() function. In the interface, ConfigureFrom() will be called first. You can save the ISMailServer pointer in your class for later reference. ConfigureFrom() is for getting the server's domain and identity settings, if you need them. The host will also call SetRejectionHandler() to register a callback. You don't have to make use of the callback function. Finally, the host will call ProcessLetter() to find out whether the letter is spam. Return TRUE if the letter IS NOT spam. Return FALSE if the letter IS spam. When you return TRUE, that doesn't mean that the letter will be accepted; it only means that processing should continue because the letter might not be spam. Additional checks may be performed by the host on the letter. ProcessLetter() may receive a pointer to the headers of the message, or it may receive a NULL pointer. In any case, you will always get the path of the message on the hard drive. In fact, you can modify the message file. All handles to the file are closed in the host before the file path is passed to ProcessLetter(). The user parameter will either be the specific user to receive the letter (when the message was downloaded from a remote POP3 server) or "SMTP" when the message was received through a direct SMTP session. The ISpamFilter interface contains methods called TrainUsingSpam() and TrainUsingHam(). Nothing on the host's side currently makes use of these methods, but should a Bayesian filter ever be written, these methods can be used by hosts to train the filter. The EnableFilter() and CheckFilter() methods can be used by the host (though not currently used) to enable or disable the filter without completely unloading the filter from memory. The final four methods of the interface deal with E-Mail addresses. At one point, I thought about having the filter deal with white lists and such, but I have since moved that into the host. These methods are therefore unused and should return FALSE, although CheckSafeAddress() should probably return TRUE. The most important consideration of writing a spam filter for SimbeyMail is to make it thread safe. The spam filter will only be called for one directly received message at a time, and it will also only be called once at a time for proxied messages, but it may be called for both at the same time from different threads. So that's the basics to writing a spam filter for SimbeyMail! I would be very happy to have someone write a filter for SimbeyMail, and should anyone want to write a filter, I would definitely be more than happy to help! |
|||
![]() |
|