Skip to content

Spam traps

A spam trap is an address that no person uses and that is never given out for legitimate correspondence. Typically, it is published only where address harvesters will find it, for example in hidden text on a web page. Since nobody has a legitimate reason to write to it, every message sent to a spam trap is spam by definition.

That certainty makes a trap useful in two ways. The filter can mark the messages sent to it as spam with confidence, and the messages are a reliable source of spam for training the statistical classifier.

A spam trap needs two things: the SMTP server must accept the address, and the address must be listed as a trap. The first step is easy to overlook, because a trap that the server refuses never sees any mail.

  1. Make the address an accepted local recipient: an address of an account, an alias, or an address covered by the domain’s catch-all address (Addresses, aliases and catch-all). An address that does not exist is rejected at RCPT TO with 550 5.1.1 Mailbox does not exist., and the message never reaches the spam filter.
  2. Add the address to the spam-traps list, as a MemoryLookupKey with the namespace spam-traps. These keys are found in the WebUI under Settings › Spam Filter › Lists › Spam Traps. The following object adds trap@example.org:
{
"namespace": "spam-traps",
"key": "trap@example.org"
}

The filter compares each recipient address as the sender gave it at RCPT TO, before aliases or catch-all rules rewrite it. The list therefore contains the trap addresses themselves, not the account they are delivered to.

A message sent to a trap address receives the SPAM_TRAP tag, which scores 15.0 in the rule set. With the default thresholds, that score alone makes the message spam. The statistical classifier is not consulted for the message, because the verdict is already certain.

In every other respect, the message is processed like any other. It is delivered to the Junk folder of the account that receives the trap address, unless a reject or discard threshold below its score applies.

To drop trapped messages instead of storing them, set the SPAM_TRAP tag to discard with a SpamTag of the Discard variant, as shown in Scores. The discard applies to the whole message, so a message sent to a trap and to other recipients is then discarded for all of them.

Each trapped message that is classified as spam is also stored as a spam sample for the classifier, as described in Automatic learning. This source of samples is controlled by learnSpamFromTraps on the SpamClassifier singleton, which is enabled by default.