smtplib

SMTP/ESMTP client class.

This should follow RFC 821 (SMTP), RFC 1869 (ESMTP), RFC 2554 (SMTP Authentication) and RFC 2487 (Secure SMTP over TLS).

Notes:

Please remember, when doing ESMTP, that the names of the SMTP service extensions are NOT the same thing as the option keywords for the RCPT and MAIL commands!

Example:

>>> import smtplib
>>> s=smtplib.SMTP("localhost")
>>> print s.help()
This is Sendmail version 8.8.4
Topics:
    HELO    EHLO    MAIL    RCPT    DATA
    RSET    NOOP    QUIT    HELP    VRFY
    EXPN    VERB    ETRN    DSN
For more info use "HELP <topic>".
To report bugs in the implementation send email to
    sendmail-bugs@sendmail.org.
For local information send email to Postmaster at your site.
End of HELP info
>>> s.putcmd("vrfy","someone@here")
>>> s.getreply()
(250, "Somebody OverHere <somebody@here.my.org>")
>>> s.quit()

Functions

encode_base64(s[, binary, maxlinelen, eol]) Encode a string with base64.
quoteaddr(addr) Quote a subset of the email addresses defined by RFC 821.
quotedata(data) Quote data for email.

Classes

LMTP([host, port, local_hostname]) LMTP - Local Mail Transfer Protocol
SMTP([host, port, local_hostname, timeout]) This class manages a connection to an SMTP or ESMTP server.
SMTP_SSL([host, port, local_hostname, ...]) This is a subclass derived from SMTP that connects over an SSL encrypted socket (to use this class you need a socket module that was compiled with SSL support).
SSLFakeFile(sslobj) A fake file like object that really wraps a SSLObject.

Exceptions

SMTPAuthenticationError(code, msg) Authentication error.
SMTPConnectError(code, msg) Error during connection establishment.
SMTPDataError(code, msg) The SMTP server didn’t accept the data.
SMTPException Base class for all exceptions raised by this module.
SMTPHeloError(code, msg) The server refused our HELO reply.
SMTPRecipientsRefused(recipients) All recipient addresses refused.
SMTPResponseException(code, msg) Base class for all exceptions that include an SMTP error code.
SMTPSenderRefused(code, msg, sender) Sender address refused.
SMTPServerDisconnected Not connected to any SMTP server.