Package defining the class containing a standard SMTP reply made up of a code and a message, as well as a few pre-defined standard replies.

class slimta.smtp.reply.Reply([code=None[, message=None[, command=None[, address=None]]]])

Bases: object

Defines a standard SMTP reply, which can be made up of a code, an intelligent ENHANCEDSTATUSCODES string, and a free-form message. This object may or may not be immediately populated with real data.

  • code – The three-digit SMTP code.

  • message – Message part of the reply, possibly prefixed with an ENHANCEDSTATUSCODES string.

  • command – The command that is waiting for the reply, typically for logging or debugging.

  • address – Information about the remote host that gave the reply, see socket for details.

__init__([code=None[, message=None[, command=None[, address=None]]]])

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


Boolean defining whether a newline should be sent before the reply, which is useful for asynchronous replies such as timeouts.


Return self==value.


Converts the reply into a string that shows appropriate internals of the object.

Return type



Converts the reply into a single bytestring.


The code, ENHANCEDSTATUSCODES string, and the message, separated by spaces.

Return type



Defines the truth-testing operation for Reply objects. This will evaluate True if the object value set to its code attribute other than None. This is useful for checking replies that may be buffered and not yet populatd..

Return type

True or False


Checks if the full reply string contains the given sub-string.


substr – The sub-string to check for.

Return type

True or False


Converts the reply into a single string.


The code, ENHANCEDSTATUSCODES string, and the message, separated by spaces.

Return type



Direct-copies the given reply code and message into the current object. This is generally useful for sending pre-defined responses.


reply – A Reply object to copy.


Populates the object with the code and message received from the session.


ioIO object to use to receive the reply.

send(io[, flush=False])

Sends the reply to the session.

  • ioIO object to use to send the reply.

  • flush – If True, flush the send buffer after sending.


Checks if the SMTP reply indicates an error, which will be True if the code begins with a 4 or 5.

Return type

True or False

property code

Holds the reply code, which can only be set to a string containing three digits.

property message

Gets and sets the reply message. If you set this property with an ENHANCEDSTATUSCODES string prefixed, that string will be pulled out and set in the enhanced_status_code.

property enhanced_status_code

Holds the ENHANCEDSTATUSCODES string. This property is usually set automatically by the message property.


list of weak references to the object (if defined)

slimta.smtp.reply.unknown_command = <Reply code='500' message='5.5.2 Syntax error, command unrecognized'>

Reply sent when an unknown SMTP command is received by a server.

slimta.smtp.reply.unknown_parameter = <Reply code='504' message='5.5.4 Command parameter not implemented'>

Reply sent when a parameter is sent that is not supported.

slimta.smtp.reply.bad_sequence = <Reply code='503' message='5.5.1 Bad sequence of commands'>

Reply sent when commands are sent out of standard SMTP sequence.

slimta.smtp.reply.bad_arguments = <Reply code='501' message='5.5.4 Syntax error in parameters or arguments'>

Reply sent when an expected parameter is invalid.

slimta.smtp.reply.timed_out = <Reply code='421' message='4.4.2 Connection timed out'>

Reply sent when the server times out waiting for data from the client.

slimta.smtp.reply.unhandled_error = <Reply code='421' message='4.3.0 Unhandled system error'>

Reply sent when an unhandled exception is raised in a command handler.

slimta.smtp.reply.connection_failed = <Reply code='451' message='4.3.0 Connection failed'>

Reply sent when a connection fails unexpectedly.

slimta.smtp.reply.tls_failure = <Reply code='421' message='4.7.0 TLS negotiation failed'>

Reply sent when a TLS negotiation error occurs.

slimta.smtp.reply.invalid_credentials = <Reply code='535' message='5.7.8 Authentication credentials invalid'>

Reply sent when an authentication attempt resulted in invalid credentials.