From: Jesus Cea Date: Wed, 26 Dec 2012 15:47:40 +0000 (+0100) Subject: MERGE: Closes #16789: :meth:`quit` links to constants instead of own module X-Git-Tag: v3.3.1rc1~479 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa24468c9b6336e0f665445f5552cb09eaba9697;p=python MERGE: Closes #16789: :meth:`quit` links to constants instead of own module --- aa24468c9b6336e0f665445f5552cb09eaba9697 diff --cc Doc/library/smtplib.rst index 711981f3e2,4a539fc502..40b2561c6b --- a/Doc/library/smtplib.rst +++ b/Doc/library/smtplib.rst @@@ -29,34 -29,14 +29,35 @@@ Protocol) and :rfc:`1869` (SMTP Servic 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). + 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:`quit` methods. An example is included below. + :meth:`sendmail`, and :meth:`~smtplib.quit` methods. + An example is included below. + The :class:`SMTP` class supports the :keyword:`with` statement. When used + like this, the SMTP ``QUIT`` command is issued automatically when the + :keyword:`with` statement exits. E.g.:: -.. class:: SMTP_SSL(host='', port=0, local_hostname=None, keyfile=None, certfile=None[, timeout]) + >>> from smtplib import SMTP + >>> with SMTP("domain.org") as smtp: + ... smtp.noop() + ... + (250, b'Ok') + >>> + + .. versionchanged:: 3.3 + Support for the :keyword:`with` statement was added. + + .. versionchanged:: 3.3 + source_address argument was added. + +.. class:: SMTP_SSL(host='', port=0, local_hostname=None, keyfile=None, certfile=None[, timeout], context=None, source_address=None) A :class:`SMTP_SSL` instance behaves exactly the same as instances of :class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is