diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-04-13 18:37:22 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-04-13 18:37:22 (GMT) |
commit | 2fc97e6a2d97f98d4eaeb8fcb046f88d69facebb (patch) | |
tree | 8bf8762f0437a88967e1a98cb44523a3a1a300ee | |
parent | 616f2fe28ca3fdc54e4a04790ed287b845240e6c (diff) | |
download | cpython-2fc97e6a2d97f98d4eaeb8fcb046f88d69facebb.zip cpython-2fc97e6a2d97f98d4eaeb8fcb046f88d69facebb.tar.gz cpython-2fc97e6a2d97f98d4eaeb8fcb046f88d69facebb.tar.bz2 |
#2118: clarify smtplib exception documentation.
-rw-r--r-- | Doc/library/smtplib.rst | 28 | ||||
-rwxr-xr-x | Lib/smtplib.py | 5 |
2 files changed, 19 insertions, 14 deletions
diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst index 044bbde..cad4b41 100644 --- a/Doc/library/smtplib.rst +++ b/Doc/library/smtplib.rst @@ -25,8 +25,9 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions). A :class:`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 :meth:`connect` method is called - with those parameters during initialization. An :exc:`SMTPConnectError` is - raised if the specified host doesn't respond correctly. The optional + with those parameters during initialization. If the :meth:`connect` call + returns anything other 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). @@ -73,7 +74,8 @@ A nice selection of exceptions is defined as well: .. exception:: SMTPException - Base exception class for all exceptions raised by this module. + The base exception class for all the other excpetions provided by this + module. .. exception:: SMTPServerDisconnected @@ -152,15 +154,6 @@ An :class:`SMTP` instance has the following methods: for connection and for all messages sent to and received from the server. -.. method:: SMTP.connect([host[, port]]) - - 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. - - .. method:: SMTP.docmd(cmd, [, argstring]) Send a command *cmd* to the server. The optional argument *argstring* is simply @@ -177,6 +170,17 @@ An :class:`SMTP` instance has the following methods: :exc:`SMTPServerDisconnected` will be raised. +.. method:: SMTP.connect([host[, port]]) + + 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 response. + + .. method:: SMTP.helo([hostname]) Identify yourself to the SMTP server using ``HELO``. The hostname argument diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 9e8bc72..a3213b3 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -237,8 +237,9 @@ class SMTP: If specified, `host' is the name of the remote host to which to connect. If specified, `port' specifies the port to which to connect. - By default, smtplib.SMTP_PORT is used. An SMTPConnectError is raised - if the specified `host' doesn't respond correctly. If specified, + By default, smtplib.SMTP_PORT is used. If a host is specified the + connect method is called, and if it returns anything other than + a success code an SMTPConnectError is raised. If specified, `local_hostname` is used as the FQDN of the local host. By default, the local hostname is found using socket.getfqdn(). |