smtplib.SMTP.ehlo()

SMTP.ehlo(name='') Identify yourself to an ESMTP server using EHLO. The hostname argument defaults to the fully qualified domain name of the local host. Examine the response for ESMTP option and store them for use by has_extn(). Also sets several informational attributes: the message returned by the server is stored as the ehlo_resp attribute, does_esmtp is set to true or false depending on whether the server supports ESMTP, and esmtp_features will be a dictionary containing the names of the

smtplib.SMTP.docmd()

SMTP.docmd(cmd, args='') Send a command cmd to the server. The optional argument args is simply concatenated to the command, separated by a space. This returns a 2-tuple composed of a numeric response code and the actual response line (multiline responses are joined into one long line.) In normal operation it should not be necessary to call this method explicitly. It is used to implement other methods and may be useful for testing private extensions. If the connection to the server is lost w

smtplib.SMTP.connect()

SMTP.connect(host='localhost', port=0) Connect to a host on a given port. The defaults are to connect to the local host at the standard SMTP port (25). If the hostname ends with a colon (':') followed by a number, that suffix will be stripped off and the number interpreted as the port number to use. This method is automatically invoked by the constructor if a host is specified during instantiation. Returns a 2-tuple of the response code and message sent by the server in its connection respon

smtplib.SMTP.auth()

SMTP.auth(mechanism, authobject, *, initial_response_ok=True) Issue an SMTP AUTH command for the specified authentication mechanism, and handle the challenge response via authobject. mechanism specifies which authentication mechanism is to be used as argument to the AUTH command; the valid values are those listed in the auth element of esmtp_features. authobject must be a callable object taking an optional single argument: data = authobject(challenge=None) If optional keyword argument ini

smtplib.SMTP

class smtplib.SMTP(host='', port=0, local_hostname=None, [timeout, ]source_address=None) An SMTP instance encapsulates an SMTP connection. It has methods that support a full repertoire of SMTP and ESMTP operations. If the optional host and port parameters are given, the SMTP connect() method is called with those parameters during initialization. If specified, local_hostname is used as the FQDN of the local host in the HELO/EHLO command. Otherwise, the local hostname is found using socket.get

smtplib.LMTP

class smtplib.LMTP(host='', port=LMTP_PORT, local_hostname=None, source_address=None) The LMTP protocol, which is very similar to ESMTP, is heavily based on the standard SMTP client. It’s common to use Unix sockets for LMTP, so our connect() method must support that as well as a regular host:port server. The optional arguments local_hostname and source_address have the same meaning as they do in the SMTP class. To specify a Unix socket, you must use an absolute path for host, starting with a

smtpd.SMTPServer.process_message()

process_message(peer, mailfrom, rcpttos, data, **kwargs) Raise a NotImplementedError exception. Override this in subclasses to do something useful with this message. Whatever was passed in the constructor as remoteaddr will be available as the _remoteaddr attribute. peer is the remote host’s address, mailfrom is the envelope originator, rcpttos are the envelope recipients and data is a string containing the contents of the e-mail (which should be in RFC 5321 format). If the decode_data const

smtpd.SMTPServer.channel_class

channel_class Override this in subclasses to use a custom SMTPChannel for managing SMTP clients.

smtpd.SMTPServer

class smtpd.SMTPServer(localaddr, remoteaddr, data_size_limit=33554432, map=None, enable_SMTPUTF8=False, decode_data=True) Create a new SMTPServer object, which binds to local address localaddr. It will treat remoteaddr as an upstream SMTP relayer. It inherits from asyncore.dispatcher, and so will insert itself into asyncore‘s event loop on instantiation. data_size_limit specifies the maximum number of bytes that will be accepted in a DATA command. A value of None or 0 means no limit. map is

smtpd.SMTPChannel.smtp_state

smtp_state Holds the current state of the channel. This will be either COMMAND initially and then DATA after the client sends a “DATA” line.