Home
Ratchet Library :: API Reference
API  ·  Manual

Module ratchet.smtp.server

This library provides server-side capabilities for an SMTP server. Currently the server will advertize the 8BITMIME, PIPELINING, and ENHANCEDSTATUSCODES extensions and is capable of handling arbitrary, custom commands as well. It is provided for convenience and as an example of using the ratchet libraries.

Functions

__call (self) An alias to the handle() method, allowing the smtp.server object to be callable as if it were a function.
handle (self) Sends a banner and starts listening for and responding to SMTP commands from the client.
new (socket, handlers, tls_context, tls_immediately) Creates a new SMTP server object.


Functions

__call (self)
An alias to the handle() method, allowing the smtp.server object to be callable as if it were a function.

Parameters

  • self: the smtp.server object.
handle (self)
Sends a banner and starts listening for and responding to SMTP commands from the client. This function continues until the client sends a QUIT command.

Parameters

  • self: the smtp.server object.
new (socket, handlers, tls_context, tls_immediately)
Creates a new SMTP server object. A new object should be created with this function for each socket created by accept()'ing a new connection on a listening socket.

Parameters

  • socket: Used as the underlying socket for the session, under the assumption that no I/O has taken place, except possibly encryption if not using STARTTLS.
  • handlers: Table whose keys correspond to supported SMTP commands. The command is called as a method of this table, e.g. handlers:MAIL(...), with the first argument being a reply table that the method can use to set the "code" and "message" keys to control the response. See the manual for more details.
  • tls_context: If given as a ratchet.ssl context object, the STARTTLS extension will be enabled allowing clients to encrypt the session. If given as boolean true, it is assumed that the socket was previously encrypted and the session is secure.
  • tls_immediately: If enabled, instead of providing the STARTTLS extension, the connection would be immediately encrypted with tls_context before sending the banner.

Return value:

a new smtp.server object.