slimta.policy.spamassassin

Package containing a QueuePolicy for connecting to spamd (SpamAssassin) and checking if a message is spammy. If used as a QueuePolicy, the header X-Spam-Status will be YES if spammy (with matched symbols in X-Spam-Symbols).

exception slimta.policy.spamassassin.SpamAssassinError

Bases: slimta.policy.PolicyError

This exception occurs when malformed or error data was received from the SpamAssassin server. This means the server is broken or misconfigured, it does not imply the message is spammy or clean.

class slimta.policy.spamassassin.SpamAssassin([address=None[, timeout=None[, socket_creator=None]]])

Bases: slimta.policy.QueuePolicy

Queries spamd to check if a given message is spammy.

Parameters
  • address – Address tuple of the spamd server, defaults to ('localhost', 783).

  • timeout – Timeout to use while waiting for spamd response.

scan(message)

Convenience method that scans a message and returns the results, without adding the spam headers.

Parameters

message (bytes or Envelope) – Message to scan.

Returns

Tuple of a spammy boolean followed by a list of the symbols matched in the scan.

apply(envelope)

QueuePolicy sub-classes must override this method, which will be called by the Queue before storage.

Parameters

envelope – The Envelope object the policy execution should apply any changes to. This envelope object may be modified, though if new envelopes are returned this object is discarded.

Returns

Optionally return or generate an iterable of Envelope objects to replace the given envelope going forward. Returning None or an empty list will keep using envelope.