slimta.relay

Root package for relaying messages to their next destination. A relay could be another SMTP hop, or it could be implemented as a final delivery mechanism.

exception slimta.relay.PermanentRelayError(msg[, reply=None])

Bases: slimta.relay.RelayError

Base exception for all relay errors that indicate a message will not be successfully delivered no matter how many times delivery is attempted.

exception slimta.relay.TransientRelayError(msg[, reply=None])

Bases: slimta.relay.RelayError

Base exception for all relay errors that indicate the message may be successful if tried again later.

class slimta.relay.Relay

Bases: object

Base class for objects that implement the relaying pattern. Included implementations are MxSmtpRelay and StaticSmtpRelay.

add_policy(policy)

Adds a RelayPolicy to be executed each time the relay attempts delivery for a message.

Parameters:policyRelayPolicy object to execute.
attempt(envelope, attempts)

This method must be overridden by sub-classes in order to be passed in to the Queue constructor.

The result of a successful relay attempt is either None or a Reply object. The result of a failing relay attempt is either a PermanentRelayFailure or TransientRelayFailure error.

If the result applies to the entire envelope and all its recipients, implementations may return the successful result or raise the failure. If the result is different per-recipient, then implementations may return a dictionary where the key is a recipient from recipients and the value is the relay result (successful or failing).

Parameters:
  • envelopeEnvelope to attempt delivery for.
  • attempts – Number of times the envelope has attempted delivery.
Returns:

The relay result, as described above.

Raises:

PermanentRelayError, TransientRelayError

kill()

This method is used by Relay and Relay-like objects to properly end associated services (such as running Greenlet threads) and close resources.


Sub-Modules: