Merge heads.

This commit is contained in:
R David Murray 2013-06-23 16:12:32 -04:00
commit 65e27fccdc
2 changed files with 42 additions and 31 deletions

View File

@ -24,12 +24,15 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
A :class:`SMTP` instance encapsulates an SMTP connection. It has methods A :class:`SMTP` instance encapsulates an SMTP connection. It has methods
that support a full repertoire of SMTP and ESMTP operations. If the optional that support a full repertoire of SMTP and ESMTP operations. If the optional
host and port parameters are given, the SMTP :meth:`connect` method is called host and port parameters are given, the SMTP :meth:`connect` method is
with those parameters during initialization. If the :meth:`connect` call called with those parameters during initialization. If specified,
returns anything other than a success code, an :exc:`SMTPConnectError` is *local_hostname* is used as the FQDN of the local host in the HELO/EHLO
raised. The optional *timeout* parameter specifies a timeout in seconds for command. Otherwise, the local hostname is found using
blocking operations like the connection attempt (if not specified, the :func:`socket.getfqdn`. If the :meth:`connect` call returns anything other
global default timeout setting will be used). than a success code, an :exc:`SMTPConnectError` is raised. The optional
*timeout* parameter specifies a timeout in seconds for blocking operations
like the connection attempt (if not specified, the global default timeout
setting will be used).
For normal use, you should only require the initialization/connect, For normal use, you should only require the initialization/connect,
:meth:`sendmail`, and :meth:`~smtplib.quit` methods. :meth:`sendmail`, and :meth:`~smtplib.quit` methods.
@ -45,12 +48,13 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
:class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is :class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is
required from the beginning of the connection and using :meth:`starttls` is required from the beginning of the connection and using :meth:`starttls` is
not appropriate. If *host* is not specified, the local host is used. If not appropriate. If *host* is not specified, the local host is used. If
*port* is omitted, the standard SMTP-over-SSL port (465) is used. *keyfile* *port* is omitted, the standard SMTP-over-SSL port (465) is used.
and *certfile* are also optional, and can contain a PEM formatted private key *local_hostname* has the same meaning as it does for the :class:`SMTP`
and certificate chain file for the SSL connection. The optional *timeout* class. *keyfile* and *certfile* are also optional, and can contain a PEM
parameter specifies a timeout in seconds for blocking operations like the formatted private key and certificate chain file for the SSL connection. The
connection attempt (if not specified, the global default timeout setting optional *timeout* parameter specifies a timeout in seconds for blocking
will be used). operations like the connection attempt (if not specified, the global default
timeout setting will be used).
.. versionadded:: 2.6 .. versionadded:: 2.6
@ -58,13 +62,15 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).
.. class:: LMTP([host[, port[, local_hostname]]]) .. class:: LMTP([host[, port[, local_hostname]]])
The LMTP protocol, which is very similar to ESMTP, is heavily based on the 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 :meth:`connect` standard SMTP client. It's common to use Unix sockets for LMTP, so our
method must support that as well as a regular host:port server. To specify a :meth:`connect` method must support that as well as a regular host:port
Unix socket, you must use an absolute path for *host*, starting with a '/'. server. *local_hostname* has the same meaning as it does for the
:class:`SMTP` class. To specify a Unix socket, you must use an absolute
path for *host*, starting with a '/'.
Authentication is supported, using the regular SMTP mechanism. When using a Unix Authentication is supported, using the regular SMTP mechanism. When using a
socket, LMTP generally don't support or require any authentication, but your Unix socket, LMTP generally don't support or require any authentication, but
mileage might vary. your mileage might vary.
.. versionadded:: 2.6 .. versionadded:: 2.6

View File

@ -238,10 +238,11 @@ class SMTP:
If specified, `host' is the name of the remote host to which to If specified, `host' is the name of the remote host to which to
connect. If specified, `port' specifies the port to which to connect. connect. If specified, `port' specifies the port to which to connect.
By default, smtplib.SMTP_PORT is used. If a host is specified the By default, smtplib.SMTP_PORT is used. If a host is specified the
connect method is called, and if it returns anything other than connect method is called, and if it returns anything other than a
a success code an SMTPConnectError is raised. If specified, success code an SMTPConnectError is raised. If specified,
`local_hostname` is used as the FQDN of the local host. By default, `local_hostname` is used as the FQDN of the local host for the
the local hostname is found using socket.getfqdn(). HELO/EHLO command. Otherwise, the local hostname is found using
socket.getfqdn().
""" """
self.timeout = timeout self.timeout = timeout
@ -759,12 +760,15 @@ class SMTP:
if _have_ssl: if _have_ssl:
class SMTP_SSL(SMTP): class SMTP_SSL(SMTP):
""" This is a subclass derived from SMTP that connects over an SSL encrypted """ This is a subclass derived from SMTP that connects over an SSL
socket (to use this class you need a socket module that was compiled with SSL encrypted socket (to use this class you need a socket module that was
support). If host is not specified, '' (the local host) is used. If port is compiled with SSL support). If host is not specified, '' (the local
omitted, the standard SMTP-over-SSL port (465) is used. keyfile and certfile host) is used. If port is omitted, the standard SMTP-over-SSL port
are also optional - they can contain a PEM formatted private key and (465) is used. local_hostname has the same meaning as it does in the
certificate chain file for the SSL connection. SMTP class. keyfile and certfile are also optional - they can contain
a PEM formatted private key and certificate chain file for the SSL
connection.
""" """
default_port = SMTP_SSL_PORT default_port = SMTP_SSL_PORT
@ -795,9 +799,10 @@ class LMTP(SMTP):
"""LMTP - Local Mail Transfer Protocol """LMTP - Local Mail Transfer Protocol
The LMTP protocol, which is very similar to ESMTP, is heavily based 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, on the standard SMTP client. It's common to use Unix sockets for
so our connect() method must support that as well as a regular LMTP, so our connect() method must support that as well as a regular
host:port server. To specify a Unix socket, you must use an absolute host:port server. local_hostname has the same meaning as it does in
the SMTP class. To specify a Unix socket, you must use an absolute
path as the host, starting with a '/'. path as the host, starting with a '/'.
Authentication is supported, using the regular SMTP mechanism. When Authentication is supported, using the regular SMTP mechanism. When