diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-04-13 18:42:36 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-04-13 18:42:36 (GMT) |
commit | c1d3daf58b8df00e680e91f0e568270ea8e85adb (patch) | |
tree | f3d8f195ffc27857b593fd6984a70b9299494b9f /Doc | |
parent | 6d80046628759bc721640f7f888aa386529d0239 (diff) | |
parent | 0bfd6acf03640f8910b8f9fa10cc7775a7c55449 (diff) | |
download | cpython-c1d3daf58b8df00e680e91f0e568270ea8e85adb.zip cpython-c1d3daf58b8df00e680e91f0e568270ea8e85adb.tar.gz cpython-c1d3daf58b8df00e680e91f0e568270ea8e85adb.tar.bz2 |
Merge #2118: clarify smtplib exception documentation.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/smtplib.rst | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst index 40b2561..9593dea 100644 --- a/Doc/library/smtplib.rst +++ b/Doc/library/smtplib.rst @@ -25,16 +25,16 @@ 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 - *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). The optional source_address parameter allows to bind to some - specific source address in a machine with multiple network interfaces, - and/or to some specific source TCP port. It takes a 2-tuple (host, port), - for the socket to bind to as its source address before connecting. If - omitted (or if host or port are ``''`` and/or 0 respectively) the OS default - behavior will be used. + 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). The optional source_address + parameter allows to bind to some specific source address in a machine with + multiple network interfaces, and/or to some specific source TCP port. It + takes a 2-tuple (host, port), for the socket to bind to as its source + address before connecting. If omitted (or if host or port are ``''`` and/or + 0 respectively) the OS default behavior will be used. For normal use, you should only require the initialization/connect, :meth:`sendmail`, and :meth:`~smtplib.quit` methods. @@ -103,7 +103,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 @@ -182,15 +183,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='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. - - .. method:: SMTP.docmd(cmd, args='') Send a command *cmd* to the server. The optional argument *args* is simply @@ -207,6 +199,17 @@ An :class:`SMTP` instance has the following methods: :exc:`SMTPServerDisconnected` will be raised. +.. method:: 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 response. + + .. method:: SMTP.helo(name='') Identify yourself to the SMTP server using ``HELO``. The hostname argument |