slimta.relay.http

This module contains a Relay class that delivers mail using the HTTP or HTTPS protocols. This is done in the same way that slimta.edge.wsgi receives mail, making the two compatible for exchanging mail.

class slimta.relay.http.HttpRelay(url[, pool_size=None[, context=None[, ehlo_as=None[, timeout=None[, idle_timeout=None]]]]])

Bases: slimta.relay.pool.RelayPool

Implements a Relay that attempts to deliver mail with an HTTP or HTTPS request. This request contains all the information that would usually go through an SMTP session as headers: the EHLO string, envelope sender and recipients.

A 200 OK (or similar) response from the server will inform the caller that the message was successfully delivered. In other cases, the class makes its best guess about whether to raise a PermanentRelayError or TransientRelayError. If the server’s response includes a X-Smtp-Reply header, it will be used. This header looks like:

X-Smtp-Reply: 550; message="5.0.0 Some error message"
Parameters:
  • url – URL string to make requests against. This string is parsed with urlparse.urlsplit() with 'http' as the default scheme.
  • 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, when https URLs are used, rather than the default context.
  • ehlo_as – The string to send as the EHLO string in a header. Defaults to the FQDN of the system. This may also be given as a function that will be executed with no arguments at the beginning of each connection.
  • timeout – This is the maximum time in seconds to wait for the entire session: connection, request, and response. If None, there is no timeout.
  • idle_timeout – Timeout in seconds that a connection is held open waiting for another delivery request to process. By default, connections are closed immediately and not reused.
http_verb = 'POST'

The HTTP verb to use with the requests.

sender_header = 'X-Envelope-Sender'

The header name used to send the base64-encoded sender address.

recipient_header = 'X-Envelope-Recipient'

The header name used to send each base64-encoded recipient address.

ehlo_header = 'X-Ehlo'

The header name used to send the EHLO string.

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