Module defining Envelope for holding message data along with metadata.

class slimta.envelope.Envelope([sender=None[, recipients=None[, headers=None[, message=None]]]])

Bases: object

Class containing message data and metadata. This class acts like an envelope with the sending address, recipient(s), and the actual message.

  • sender – The address that sent the message.
  • recipients – List of addresses to receive the message.
  • headers (email.message.Message) – The message headers.
  • message (bytes) – String containing the message contents after the headers.
sender = None

Sending address of the message.

recipients = None

List of recipient addresses of the message.

headers = None

email.message.Message object for accessing and modifying message headers.

message = None

Bytestring of message data, not including headers.

client = None

Dictionary of information about the client that sent the message. Utilized keys include:

  • ip: The IP of the client.
  • host: The reverse-lookup of the client IP.
  • name: The client name, as given by its EHLO or
  • protocol: The protocol used by the client, generally a variant
    of "SMTP".
  • auth: The name the client successfully authenticated with, or
receiver = None

Hostname of the slimta server that received the message.

timestamp = None

Timestamp when the message was received.

prepend_header(name, value)

This method allows prepending a header to the message. The headers object does not directly support header prepending because the Python implementation only provides appending.


Builds and returns an exact copy if the current object. This method uses a deep-copying so internal datastructures are not shared.

Parameters:new_rcpts – If given, overwrite the recipients list with this value in the new object.
Returns:An exact, deep copy of the current object.

Produces two strings representing the headers and message body.

Returns:Tuple of two bytestrings: (header_data, message_data)

New in version 0.3.12.

Forces the message into 7-bit encoding such that it can be sent to SMTP servers that do not support the 8BITMIME extension.

If the encoder function is not given, this function is relatively cheap and will just check the message body for 8-bit characters (raising UnicodeDecodeError if any are found). Otherwise, this method can be very expensive. It will parse the entire message into MIME parts in order to encode parts that are not 7-bit.

Parameters:encoder – Optional function from email.encoders used to encode MIME parts that are not 7-bit.

Parses the given Message to populate the headers and message attributes.

Parameters:data (Message) – The complete message, headers and message body.

Parses the given string to populate the headers and message attributes.

Parameters:data (bytes) – The complete message, headers and message body.