slimta.smtp.extensions

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.

__init__()

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

reset()

Removes all known extensions.

__contains__(ext)

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:.

Parameters:ext – The extension to check for, case-insensitive.
Return type:True or False
getparam(ext[, filter=None])

Gets the parameter associated with an extension.

Parameters:
  • 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:

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.

Parameters:
  • ext – The extension name, which will be upper-cased.
  • param – Optional parameter string associated with the extension.
drop(ext)

Drops the given extension, if it exists.

Parameters:ext – The extension name.
Returns:True if the extension existed, False otherwise.
parse_string(string)

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.

Parameters:string – The string to parse.
Returns:The first line of the string, which will be a free-form message response to the EHLO command.
build_string(header)

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

Parameters:header – The first line of the resulting string, which can be a free-form message response for the EHLO command.
Return type:str
__weakref__

list of weak references to the object (if defined)