slimta.relay.smtp.static

Implements a pool of connections to a single destination. If an existing connection is available, it is re-used by subsequent connections until it times out.

class slimta.relay.smtp.static.StaticSmtpRelay(host[, port=25[, pool_size=None[, client_class=None[, context=None[, **client_kwargs]]]]])

Bases: slimta.relay.pool.RelayPool

Manages the relaying of messages to a specific host:port. Connections may be recycled when possible, to send multiple messages over a single channel.

Parameters:
  • host – Host string to connect to.
  • port – Port to connect to.
  • pool_size – At most this many simultaneous connections will be open to the destination. If this limit is reached and no connections are idle, new attempts will block.
  • context (SSLContext) – Used to wrap sockets with SSL encryption, rather than the default context.
  • auth_mechanism (bytes) – Force the use of the given AUTH mechanism, instead of the best available.
  • tls_immediately – If True, the socket will be encrypted immediately on connection rather than looking for the STARTTLS extension.
  • tls_required – If given and True, it should be considered a delivery failure if TLS cannot be negotiated by the client.
  • connect_timeout – Timeout in seconds to wait for a client connection to be successful before issuing a transient failure.
  • command_timeout – Timeout in seconds to wait for a reply to each SMTP command before issuing a transient failure.
  • data_timeout – Timeout in seconds to wait for a reply to message data before issuing a transient failure.
  • idle_timeout – Timeout in seconds after a message is delivered before a QUIT command is sent and the connection terminated. If another message should be delivered before this timeout expires, the connection will be re-used. By default, QUIT is sent immediately and connections are never re-used.
  • credentials – Information used to authenticate the created SMTP sessions. This can be an iterable or a callable that returns or generates an iterable. The iterable will be passed as the arguments into the auth() method of the session. By default, no authentication is attempted.
  • socket_creator – Optional function to use instead of create_connection() for creating sockets.
  • ehlo_as – The string to send as the EHLO or HELO string. Defaults to the FQDN of the system. This may also be given as a function that will be executed with the destination address at the beginning of each connection.
  • binary_encoder – Optional function from email.encoders used as an argument to encode_7bit() when conversion is necessary for the remote server.
add_client()

Sub-classes must override this method to create and return a new RelayPoolClient object that will poll for delivery requests.

Return type:RelayPoolClient
class slimta.relay.smtp.static.StaticLmtpRelay([host='localhost'[, port=24[, pool_size=None[, **client_kwargs]]]])

Bases: slimta.relay.smtp.static.StaticSmtpRelay

Exactly like StaticSmtpRelay, except that the LMTP protocol is used by default instead.