|
SpamWeed Filter Extesions (SFX for short)
SpamWeed is a powerful and highly extensible spam filter / email classifier. The SFX is an interface where
users can write their own filtering rules.
SFX Description
SFX uses the "Object Pascal" language. You need to know pascal in order to write your own SFX. If you are
not a programmer, just rely on us to provide SFX module for you when necessary. SFX offers the following APIs:
function GetParam(key: string): string;
This API let you obtain required information inside your SFX code. Retrievable information are:
| Key | Meaning |
| Charset | all character sets that are used in the email |
| Identities |
possible spam identities appeard in the email. Spam identities include email address, domain names (urls)
and phone numbers. |
| FromName | name of the sender |
| FromAddress | address of the sender |
| ToName | names of the recipients |
| ToAddress | addresses of the recipients |
| ReceivedTime | time when the email is received |
| SentTime | time when the email is sent |
| Subject | subject of the email |
| Body | body of the email (decoded) |
| Attachments | list of attached file names |
| other | any tag appear in the email header is retrievable, e.g. "X-Mailer" |
procedure SetResult(res: Integer);
This API let your SFX code to notify the filter its conclusion made on the processed email:
| Result Code | Meaning |
| 0 | SFX cannot determine the email is spam or not |
| 1 | SFX determine that the email is spam |
| 2 | SFX determine that the email is not spam |
procedure SetCategory(cat: string);
This API set final destination of an email. It is only meaningful if your SFX code decide that the processed
email is not spam.
Sample Code
Suppose, you run a business. Your business has a reseller who often send you email about orders and customer
support requests. You can put the address "john@myreseller.com" to your allow list, but you would like to
distinguish between order emails from this reseller and customer support requests from him so that you can deal
with these different emails with different priority.
Based on previous communications, you noticed that all order emails from John contain the word "order" and
"quantity" and support requests do not contain these 2 words. You want to classify order emails to folder
"Orders" and other emails to folder "Supports".
program sfx;
var
Res : Integer;
Cat, Body : string;
begin
Res := 0;
if LowerCase(GetParam('FromAddress')) = 'john@myreseller.com' then
begin
Res := 2;
Body := LowerCase(GetParam('Body'));
if (Pos('order', Body) > 0) and (Pos('quantity', Body) > 0) then
Cat := 'Orders'
else
Cat := 'Supports';
end;
SetResult(Res);
SetCategory(Cat);
end.
|
|