slimta.policy.headers

Module containing several QueuePolicy implementations for handling the standard RFC headers.

class slimta.policy.headers.AddDateHeader

Bases: slimta.policy.QueuePolicy

Checks for the existence of the RFC-specified Date header, adding it if it does not exist.

build_date(timestamp)

Returns a date string in the format desired for the header. This method can be overridden to control the format.

Parameters:timestamp – Timestamp (as returned by time.time()) to convert into date string.
Returns:Date string for the header.
apply(envelope)

QueuePolicy sub-classes must override this method, which will be called by the Queue before storage.

Parameters:envelope – The Envelope object the policy execution should apply any changes to. This envelope object may be modified, though if new envelopes are returned this object is discarded.
Returns:Optionally return or generate an iterable of Envelope objects to replace the given envelope going forward. Returning None or an empty list will keep using envelope.
class slimta.policy.headers.AddMessageIdHeader([hostname=None])

Bases: slimta.policy.QueuePolicy

Checks for the existence of the RFC-specified Message-Id header, adding it if it does not exist.

Parameters:hostname – The hostname to use in the generated headers. By default, getfqdn() is used.
apply(envelope)

QueuePolicy sub-classes must override this method, which will be called by the Queue before storage.

Parameters:envelope – The Envelope object the policy execution should apply any changes to. This envelope object may be modified, though if new envelopes are returned this object is discarded.
Returns:Optionally return or generate an iterable of Envelope objects to replace the given envelope going forward. Returning None or an empty list will keep using envelope.
class slimta.policy.headers.AddReceivedHeader([date_format='%a, %d %b %Y %H:%M:%S +0000'])

Bases: slimta.policy.QueuePolicy

Adds the RFC-specified Received header to the message. This header should be added for every hop from a message’s origination to its destination.

The format of this header is unusual, here is a good description: http://cr.yp.to/immhf/envelope.html

apply(envelope)

QueuePolicy sub-classes must override this method, which will be called by the Queue before storage.

Parameters:envelope – The Envelope object the policy execution should apply any changes to. This envelope object may be modified, though if new envelopes are returned this object is discarded.
Returns:Optionally return or generate an iterable of Envelope objects to replace the given envelope going forward. Returning None or an empty list will keep using envelope.