OnWorks favicon

bsfilter - Online in the Cloud

Run bsfilter in OnWorks free hosting provider over Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

This is the command bsfilter that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator



bsfilter — bayesian spam filter


bsfilter [options] [commands] < MAIL

bsfilter [options] [commands] MAIL ...


bsfilter filters out spam mails.

If commands are specified, bsfilter is in maintenance mode, otherwise it is in filtering

If bsfilter does not find spam in filtering mode, exit status is 1.

If bsfilter runs with --pipe option or finds spam, exit status is 0.



-c add mails into the clean token database.


-s add mails into the spam token database.


-C subtract mails from the clean token database.


-S subtract mails from the spam token database.


-u update the probability table from clean and spam token databases.

export the clean token database.

export the spam token database.

import the clean token database.

import the spam token database.

export the probability database (for debugging purpose).


--homedir directory
specify the name of the bsfilter's home directory.

If this option is not used, a directory specified with the environment variable

If the variable "BSFILTERHOME" is not defined, ".bsfilter" directory under your
home is used.

If the variable "HOME" is not defined, a directory which bsfilter is located at
is used.

--config-file file
specify the name of the bsfilter's configuration file "bsfilter.conf" in
bsfilter's home directory is used by default.

--max-line number
check and/or study the first number of lines default is 500. 0 means all.

--db sdbm|gdbm|bdb1|bdb|qdbm
specify the name of database type "sdbm" by default.

--jtokenizer bigram|block|mecab|chasen|kakasi

-j bigram|block|mecab|chasen|kakasi
specify algorithm of a tokenizer for Japanese language "bigram" by default.

print filename of clean mail.

print filename of spam.

--imap access IMAP server.

--imap-server hostname
specify hostname of IMAP server.

--imap-port number
specify port number of IMAP server. default is 143.

--imap-auth method
specify authorization method. default is "auto". "cram-md5" use "AUTHENTICATE
CRAM-MD5" command. "login" use "AUTHENTICATE LOGIN" command. "loginc" use
"LOGIN" command. "auto" try "cram-md5", "login" and "loginc" in this order.

--imap-user name
specify user name of IMAP server.

--imap-password password
specify password of imap-user.

--imap-folder-clean folder
specify destination folder for clean mails. "inbox.clean" for example.

--imap-folder-spam folder
specify destination folder for spams. "inbox.spam" for example.

filter or study mails without SEEN flag.

filter or study mails without "X-Spam-Flag" header.

reset SEEN flag when bsfilter moves or modifies mails.

--pop work as POP proxy.

--pid-file file
specify filename for logging process ID of bsfilter "bsfilter.pid" in bsfilter's
home directory is used by default this function is valid when "--pop" is

sit in tasktray this is valid with "--pop" on VisualuRuby.

--pop-server hostname
specify hostname of POP server.

--pop-port number
specify port number of POP server. default is 110.

--pop-proxy-if address
specify address of interface which bsfilter listens at default is and
all interfaces are active.

--pop-proxy-port number
specify port number which bsfilter listens at. default is 10110.

--pop-user name
optional. specify username of POP server.

bsfilter checks match between value of this options and a name which MUA sends.

in case of mismatch, bsfilter closes sockets.

--pop-proxy-set set[,set...]
specify rules of pop proxy.

alternative way of pop-server, pop-port, pop-proxy-port and pop-user option.

format of "set" is "pop-server:pop-port:[proxy-interface]:proxy-port[:pop-

If proxy-interface is specified and isn't , other interfaces are not

"--pop-proxy-set" is equivalent with "--pop-server --pop-port 110 --pop-proxy-port 10110".

--pop-max-size number
When mail is longer than the specified number, the mail is not filtered. When 0
is specified, all mails are tested and filtered. unit is byte. default is

--ssl use POP over SSL with --pop option and use IMAP over SSL with --imap option.

--ssl-cert filename|dirname
specify a filename of a certificate of a trusted CA or a name of a directory of

--method g|r|rf

-m g|r|rf specify filtering method. "rf" by default. "g" means Paul Graham method, "r"
means Gary Robinson method, and "rf" means Robinson-Fisher method.

--spam-cutoff number
specify spam-cutoff value. 0.9 by default for Paul Graham method. 0.582 by
default for Gary Robinson method. 0.95 by default for Robinson-Fisher method.


-a recognize mails, add them into clean or spam token database and update the
probability table.


-D disable degeneration during probability table lookup.

disable utf-8 support.

--refer-header header[,header...]
refer specified headers of mails.

bsfilter refers Ufrom, From, To, Cc, Subject, Reply-to, Return-path, Received,
Content-Transfer-Encoding, Content-Type, charset, and Content-Disposition by

refer all headers of mails.


-H ignore headers of mails. (it is same as --refer-header "".)


-B ignore body of mails, except URL or mail address.

ignore plain text part if html part is included in the mail.

ignore text after last "A" tag.

--mark-in-token characters
specify characters which are allowable in a token "*'!" by default.

show summary of execution.

show tokens which are newly added into the token database.

--mbox use "unix from" to divide mbox format file.

--max-mail number
reduce token database when the number of stored mails is larger than this one
10000 by default.

--min-mail number
reduce token database as if this number of mails are stored 8000 by default.

--pipe write a mail to stdout. this options is invalid when "--imap" or "--pop" is

insert "X-Spam-Revision: bsfilter release..." into a mail.

insert "X-Spam-Flag: Yes" or "X-Spam-Flag: No" into a mail.

insert "X-Spam-Probability: number" into a mail.

--header-prefix string
insert "X-specified_string-..." headers, instead of "Spam". (it is valid with
--insert-flag and/or --insert-probability option.)

insert "[SPAM] " at the beginning of Subject header.

--mark-subject-prefix string
insert specified string, instead of "[SPAM] ". (it is valid with --mark-spam-
subject option.)

show numbers of tokens and mails in databases and quit.


-h show help message.


-q quiet mode.


-v verbose mode.


-d debug mode.


% bsfilter -s ~/Mail/spam/* ## add spam
% bsfilter -u -c ~/Mail/job/* ~/Mail/private/* ## add clean mails and update probability table
% bsfilter ~/Mail/inbox/1 ## show spam probability

## recipe of procmail
:0 HB
* ? bsfilter -a

## recipe of procmail
:0 fw
| bsfilter -a --pipe --insert-flag --insert-probability

Use bsfilter online using onworks.net services

Free Servers & Workstations

Download Windows & Linux apps

Linux commands