Manages the SMTP extensions offered by a server or available to a client.

class slimta.smtp.extensions.Extensions

Bases: object

Class that simplifies the usage of SMTP extensions. Along with an extension, a simple string parameter can be stored if necessary.


Initialize self. See help(type(self)) for accurate signature.


Removes all known extensions.


Checks if the given extension is in the known extensions. This is especially useful for clients to check if a server offers a certain desired extension, e.g. if 'AUTH' in extensions:.


ext – The extension to check for, case-insensitive.

Return type

True or False

getparam(ext[, filter=None])

Gets the parameter associated with an extension.

  • ext – The extension to get the parameter for.

  • filter – An optional filter function to modify the returned parameter, if it exists, e.g. int().


Returns None if the extension doesn’t exist, the extension doesn’t have a parameter, or the filter function raises ValueEror.

add(ext[, param=None])

Adds a new supported extension. This is useful for servers to advertise their offered extensions.

  • ext – The extension name, which will be upper-cased.

  • param – Optional parameter string associated with the extension.


Drops the given extension, if it exists.


ext – The extension name.


True if the extension existed, False otherwise.


Parses a string as returned by the EHLO command and adds all discovered extensions. This string should not have the response code prefixed to its lines.


string – The string to parse.


The first line of the string, which will be a free-form message response to the EHLO command.


Converts the object into a string that can be sent with the response to a EHLO command, without the code prefixed to each line.


header – The first line of the resulting string, which can be a free-form message response for the EHLO command.

Return type



list of weak references to the object (if defined)