Package defining a generic SMTP server class that can be used on a pre-connected socket. This works by calling optionally-defined callbacks in certain situations (typically when a client sends various commands).

class slimta.smtp.server.Server(socket, handlers[, address=None[, auth=False[, context=None[, tls_immediately=False[, command_timeout=None[, data_timeout=None]]]]]])

Bases: object

Class that implements an SMTP server given a connected socket. This object has an extensions attribute that is an Extensions object that contains the SMTP extensions the server supports.

  • socket (gevent.socket.socket) – Connected socket for the session.

  • handlers – Object with methods that will be called when corresponding SMTP commands are received. These methods can modify the Reply before the command response is sent.

  • address – The address of the connected client.

  • auth – If True, enable authentication with default mechanisms. May also be given as a list of SASL mechanism names to support, e.g. ['PLAIN', 'LOGIN', 'CRAM-MD5'].

  • context – Enables SSL encryption on connected sockets using the information given in the context.

  • tls_immediately – If True, the socket will be encrypted immediately on connection rather than advertising STARTTLS.

  • command_timeout – Optional timeout waiting for a command to be sent from the client.

  • data_timeout – Optional timeout waiting for data to be sent from the client.

property encrypted

True if the session transport is encrypted, False otherwise.


Runs through the SMTP session, receiving commands, calling handlers, and sending responses.


ConnectionLost or unhandled exceptions.