Edge that receives messages with the SMTP protocol.
Attempts to follow the SMTP server RFCs.
- class slimta.edge.smtp.SmtpEdge(listener, queue[, pool=None[, max_size=None[, validator_class=None[, auth=False[, context=None[, tls_immediately=False[, command_timeout=None[, data_timeout=None[, hostname=None[, session_class=None]]]]]]]]]])¶
Class that uses
slimta.smtp.serverto implement an edge service to receive messages.
(ip, port)tuple to listen on, as described in
pool – Optional greenlet pool, as described in
max_size – Maximum size of incoming messages.
SmtpValidatorssub-class to validate commands and alter replies.
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'].
SSLContext) – Enables SSL encryption on connected sockets using the information given in the context.
tls_immediately – If True, connections will be encrypted immediately before the SMTP banner, rather than advertising the
command_timeout – Seconds before the connection times out waiting for a command.
data_timeout – Seconds before the connection times out while receiving data. This is a cumulative timeout that is not tricked by the client sending data.
hostname – String identifying the local machine. See
Edgefor more details.
session_class – Optional
SmtpSessionsub-class to be used instead of the default one.
- class slimta.edge.smtp.SmtpValidators(session)¶
Base class for implementing SMTP command validators.
Sub-classes may implement some or all of the following functions. Leaving the reply argument untouched will return the default, successful reply from the command. Setting the response code to
221will close the connection.
handle_banner(reply, address): Validate connecting address before sending the SMTP banner.
handle_ehlo(reply, ehlo_as): Validate the EHLO string.
handle_helo(reply, helo_as): Validate the HELO string.
handle_auth(reply, creds): Validate an authentication attempt, given a
handle_mail(reply, sender, params): Validate the sender address.
handle_rcpt(reply, recipient, params): Validate one recipient address.
handle_data(reply): Any remaining validation before receiving data.
handle_have_data(reply, data): Validate the received message data.
handle_rset(reply): Called before replying to an RSET command.
handle_tls(): Called after a successful TLS handshake. This may be at the beginning of the session or after a STARTTLS command.
handle_tls2(ssl_socket): Identical to
handle_tls()except the new
SSLSocketis passed in as an argument.
session – When sub-classes are instantiated, instances are passed this object, stored and described in
sessionbelow, that have useful information about the current session.
This instance attribute is an object that has its own set of attributes which may be useful in validation:
address: The address tuple of the connecting client.
extended_smtp: The client used EHLO instead of HELO.
security: Security of connection,
ehlo_as: The EHLO or HELO string given by the client.
auth: A tuple of the form
(authcid, authzid)if the
client has authenticated.
Envelopebeing pieced together to send by the