Package containing useful policies, which can be configured to run before
queuing or before relaying the message with the
If a policy is applied before queuing, it is executed only once and any changes
it makes to the
Envelope will be stored persistently. This is especially
useful for tasks such as header and content modification, since these may be
more expensive operations and should only run once.
If a policy is applied before relaying, it is executed before each delivery attempt and no resulting changes will be persisted to storage. This is useful for policies that have to do with delivery, such as forwarding.
- exception slimta.policy.PolicyError([*args[, **kwargs]])¶
Base exception for all custom
- class slimta.policy.QueuePolicy([*args[, **kwargs]])¶
class MyQueuePolicy(QueuePolicy): def apply(self, env): env['X-When-Queued'] = str(time.time()) my_queue.add_policy(MyQueuePolicy())
envelope – The
Envelopeobject the policy execution should apply any changes to. This envelope object may be modified, though if new envelopes are returned this object is discarded.
Optionally return or generate an iterable of
Envelopeobjects to replace the given
envelopegoing forward. Returning
Noneor an empty list will keep using
- class slimta.policy.RelayPolicy([*args[, **kwargs]])¶
Base class for relay policies. These are run immediately before a relay attempt is made.
class MyRelayPolicy(RelayPolicy): def apply(self, env): env['X-When-Delivered'] = str(time.time()) my_relay.add_policy(MyRelayPolicy())