Skip to content

Automatic learning

Users create most training samples by marking messages, but they report slowly, and a new server has few reports at all. The spam filter can therefore add training samples on its own, when the classification of a message is certain for a reason independent of the classifier.

Automatic learning speeds up training, especially on a new server. It also carries a risk: a wrong automatic sample teaches the classifier the wrong lesson. Each source of automatic samples therefore requires strong evidence. The sources are configured on the SpamClassifier singleton, found in the WebUI under Settings › Spam Filter › Classifier.

Where a sample is learned decides which part of the model it trains. Samples learned from a message received over SMTP train the shared weights. Samples learned at delivery, when the recipient is known, train the recipient’s account as well.

Mail sent to a spam trap is spam by definition, which makes traps the most reliable source of spam samples. A message sent to a trap address and classified as spam is added as a spam sample when learnSpamFromTraps is enabled. The field is enabled by default, so a server with spam traps trains the classifier from them without further configuration.

One blocklist can be wrong about a sender, but several independent lists rarely agree by accident. This source therefore counts listings. A message classified as spam is added as a spam sample when it has received at least learnSpamFromRblHits distinct RBL_* tags that score more than 1.0, which are the tags added by the IP blocklists.

The field is 2 by default and at most 100, and 0 disables this source. A higher value demands more agreement before a message is learned. Two kinds of tag do not count: tags for addresses found in Received headers (RECEIVED_*), and the zero-scoring *_BLOCKED tags, which carry no information about the sender.

Ham is harder to learn automatically, because legitimate mail rarely carries proof of being legitimate. The trusted-sender rules provide such proof. A message that the filter classified as spam, but that a trusted-sender rule delivered to the inbox, is added as a ham sample for the recipient.

One field controls this for each rule. learnHamFromCard covers messages from an authenticated sender in the recipient’s address book, and is enabled by default. learnHamFromReply covers replies in a conversation in which the recipient has written, and is enabled by default.

These samples correct the classifier where it was wrong, which is where a sample is most informative. They require the corresponding trusted-sender rule to be enabled as well: trustContacts or trustReplies on SpamSettings.

When the AI classifier is enabled, its verdicts can also become samples. This source stays off until it is enabled with the learn setting of the AI classifier. Even then, it is selective. It samples only a fraction of the confident verdicts that agree with the final classification, and only for messages on which the statistical classifier was uncertain. Learning from AI verdicts describes the conditions.

The following object body learns from spam traps and from messages listed by at least three blocklists. It keeps learning from contacts, but does not learn from replies:

{
"learnSpamFromTraps": true,
"learnSpamFromRblHits": 3,
"learnHamFromCard": true,
"learnHamFromReply": false
}