| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | :mod:`smtplib` --- SMTP protocol client
 | 
					
						
							|  |  |  | =======================================
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. module:: smtplib
 | 
					
						
							|  |  |  |    :synopsis: SMTP protocol client (requires sockets).
 | 
					
						
							| 
									
										
										
										
											2016-06-11 15:02:54 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | .. sectionauthor:: Eric S. Raymond <esr@snark.thyrsus.com>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-11 15:02:54 -04:00
										 |  |  | **Source code:** :source:`Lib/smtplib.py`
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | .. index::
 | 
					
						
							|  |  |  |    pair: SMTP; protocol
 | 
					
						
							|  |  |  |    single: Simple Mail Transfer Protocol
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-27 20:38:46 +00:00
										 |  |  | --------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | The :mod:`smtplib` module defines an SMTP client session object that can be used
 | 
					
						
							|  |  |  | to send mail to any Internet machine with an SMTP or ESMTP listener daemon.  For
 | 
					
						
							|  |  |  | details of SMTP and ESMTP operation, consult :rfc:`821` (Simple Mail Transfer
 | 
					
						
							|  |  |  | Protocol) and :rfc:`1869` (SMTP Service Extensions).
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-30 10:56:50 +08:00
										 |  |  | .. class:: SMTP(host='', port=0, local_hostname=None[, timeout], source_address=None)
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-02 03:37:02 +00:00
										 |  |  |    An :class:`SMTP` instance encapsulates an SMTP connection.  It has methods
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r62998 | andrew.kuchling | 2008-05-10 15:51:55 -0400 (Sat, 10 May 2008) | 7 lines
  #1858 from Tarek Ziade:
  Allow multiple repositories in .pypirc; see http://wiki.python.org/moin/EnhancedPyPI
  for discussion.
  The patch is slightly revised from Tarek's last patch: I've simplified
  the PyPIRCCommand.finalize_options() method to not look at sys.argv.
  Tests still pass.
........
  r63000 | alexandre.vassalotti | 2008-05-10 15:59:16 -0400 (Sat, 10 May 2008) | 5 lines
  Cleaned up io._BytesIO.write().
  I am amazed that the old code, for inserting null-bytes, actually
  worked. Who wrote that thing? Oh, it is me... doh.
........
  r63002 | brett.cannon | 2008-05-10 16:52:01 -0400 (Sat, 10 May 2008) | 2 lines
  Revert r62998 as it broke the build (seems distutils.config is missing).
........
  r63014 | andrew.kuchling | 2008-05-10 18:12:38 -0400 (Sat, 10 May 2008) | 1 line
  #1858: add distutils.config module
........
  r63027 | brett.cannon | 2008-05-10 21:09:32 -0400 (Sat, 10 May 2008) | 2 lines
  Flesh out the 3.0 deprecation to suggest using the ctypes module.
........
  r63028 | skip.montanaro | 2008-05-10 22:59:30 -0400 (Sat, 10 May 2008) | 4 lines
  Copied two versions of the example from the interactive session.  Delete
  one.
........
  r63037 | georg.brandl | 2008-05-11 03:02:17 -0400 (Sun, 11 May 2008) | 2 lines
  reload() takes the module itself.
........
  r63038 | alexandre.vassalotti | 2008-05-11 03:06:04 -0400 (Sun, 11 May 2008) | 4 lines
  Added test framework for handling module renames.
  Factored the import guard in test_py3kwarn.TestStdlibRemovals into
  a context manager, namely test_support.CleanImport.
........
  r63039 | georg.brandl | 2008-05-11 03:06:05 -0400 (Sun, 11 May 2008) | 2 lines
  #2742: ``''`` is not converted to NULL in getaddrinfo.
........
  r63040 | alexandre.vassalotti | 2008-05-11 03:08:12 -0400 (Sun, 11 May 2008) | 2 lines
  Fixed typo in a comment of test_support.CleanImport.
........
  r63041 | alexandre.vassalotti | 2008-05-11 03:10:25 -0400 (Sun, 11 May 2008) | 2 lines
  Removed a dead line of code.
........
  r63043 | georg.brandl | 2008-05-11 04:47:53 -0400 (Sun, 11 May 2008) | 2 lines
  #2812: document property.getter/setter/deleter.
........
  r63049 | georg.brandl | 2008-05-11 05:06:30 -0400 (Sun, 11 May 2008) | 2 lines
  #1153769: document PEP 237 changes to string formatting.
........
  r63050 | georg.brandl | 2008-05-11 05:11:40 -0400 (Sun, 11 May 2008) | 2 lines
  #2809: elaborate str.split docstring a bit.
........
  r63051 | georg.brandl | 2008-05-11 06:13:59 -0400 (Sun, 11 May 2008) | 2 lines
  Fix typo.
........
  r63052 | georg.brandl | 2008-05-11 06:33:27 -0400 (Sun, 11 May 2008) | 2 lines
  #2709: clarification.
........
  r63053 | georg.brandl | 2008-05-11 06:42:28 -0400 (Sun, 11 May 2008) | 2 lines
  #2659: add ``break_on_hyphens`` to TextWrapper.
........
  r63057 | georg.brandl | 2008-05-11 06:59:39 -0400 (Sun, 11 May 2008) | 2 lines
  #2741: clarification of value range for address_family.
........
  r63058 | georg.brandl | 2008-05-11 07:09:35 -0400 (Sun, 11 May 2008) | 2 lines
  #2452: timeout is used for all blocking operations.
........
  r63059 | andrew.kuchling | 2008-05-11 09:33:56 -0400 (Sun, 11 May 2008) | 2 lines
  #1792: Improve performance of marshal.dumps() on large objects by increasing
  the size of the buffer more quickly.
........
  r63060 | andrew.kuchling | 2008-05-11 10:00:00 -0400 (Sun, 11 May 2008) | 1 line
  #1858: re-apply patch for this, adding the missing files
........
  r63061 | benjamin.peterson | 2008-05-11 10:13:25 -0400 (Sun, 11 May 2008) | 2 lines
  Add the "until" command to pdb
........
  r63062 | georg.brandl | 2008-05-11 10:17:13 -0400 (Sun, 11 May 2008) | 2 lines
  Add some sentence endings.
........
											
										 
											2008-05-16 00:03:33 +00:00
										 |  |  |    that support a full repertoire of SMTP and ESMTP operations. If the optional
 | 
					
						
							| 
									
										
										
										
											2013-06-23 16:05:44 -04:00
										 |  |  |    host and port parameters are given, the SMTP :meth:`connect` method is
 | 
					
						
							|  |  |  |    called with those parameters during initialization.  If specified,
 | 
					
						
							|  |  |  |    *local_hostname* is used as the FQDN of the local host in the HELO/EHLO
 | 
					
						
							|  |  |  |    command.  Otherwise, the local hostname is found using
 | 
					
						
							|  |  |  |    :func:`socket.getfqdn`.  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
 | 
					
						
							| 
									
										
										
										
											2014-06-09 16:41:06 -04:00
										 |  |  |    setting will be used).  If the timeout expires, :exc:`socket.timeout` is
 | 
					
						
							| 
									
										
										
										
											2016-02-10 05:44:01 +00:00
										 |  |  |    raised.  The optional source_address parameter allows binding
 | 
					
						
							| 
									
										
										
										
											2013-06-23 16:05:44 -04:00
										 |  |  |    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.
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    For normal use, you should only require the initialization/connect,
 | 
					
						
							| 
									
										
										
										
											2012-12-26 16:47:03 +01:00
										 |  |  |    :meth:`sendmail`, and :meth:`~smtplib.quit` methods.
 | 
					
						
							|  |  |  |    An example is included below.
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-15 15:04:44 -04:00
										 |  |  |    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.::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     >>> from smtplib import SMTP
 | 
					
						
							|  |  |  |     >>> with SMTP("domain.org") as smtp:
 | 
					
						
							|  |  |  |     ...     smtp.noop()
 | 
					
						
							|  |  |  |     ...
 | 
					
						
							|  |  |  |     (250, b'Ok')
 | 
					
						
							|  |  |  |     >>>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-26 18:53:42 +02:00
										 |  |  |    .. versionchanged:: 3.3
 | 
					
						
							| 
									
										
										
										
											2011-03-15 15:04:44 -04:00
										 |  |  |       Support for the :keyword:`with` statement was added.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-31 09:14:17 +08:00
										 |  |  |    .. versionchanged:: 3.3
 | 
					
						
							|  |  |  |       source_address argument was added.
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-16 13:58:14 -04:00
										 |  |  |    .. versionadded:: 3.5
 | 
					
						
							|  |  |  |       The SMTPUTF8 extension (:rfc:`6531`) is now supported.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-23 15:47:50 -04:00
										 |  |  | .. class:: SMTP_SSL(host='', port=0, local_hostname=None, keyfile=None, \
 | 
					
						
							|  |  |  |                     certfile=None [, timeout], context=None, \
 | 
					
						
							|  |  |  |                     source_address=None)
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-02 03:37:02 +00:00
										 |  |  |    An :class:`SMTP_SSL` instance behaves exactly the same as instances of
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  |    :class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r62998 | andrew.kuchling | 2008-05-10 15:51:55 -0400 (Sat, 10 May 2008) | 7 lines
  #1858 from Tarek Ziade:
  Allow multiple repositories in .pypirc; see http://wiki.python.org/moin/EnhancedPyPI
  for discussion.
  The patch is slightly revised from Tarek's last patch: I've simplified
  the PyPIRCCommand.finalize_options() method to not look at sys.argv.
  Tests still pass.
........
  r63000 | alexandre.vassalotti | 2008-05-10 15:59:16 -0400 (Sat, 10 May 2008) | 5 lines
  Cleaned up io._BytesIO.write().
  I am amazed that the old code, for inserting null-bytes, actually
  worked. Who wrote that thing? Oh, it is me... doh.
........
  r63002 | brett.cannon | 2008-05-10 16:52:01 -0400 (Sat, 10 May 2008) | 2 lines
  Revert r62998 as it broke the build (seems distutils.config is missing).
........
  r63014 | andrew.kuchling | 2008-05-10 18:12:38 -0400 (Sat, 10 May 2008) | 1 line
  #1858: add distutils.config module
........
  r63027 | brett.cannon | 2008-05-10 21:09:32 -0400 (Sat, 10 May 2008) | 2 lines
  Flesh out the 3.0 deprecation to suggest using the ctypes module.
........
  r63028 | skip.montanaro | 2008-05-10 22:59:30 -0400 (Sat, 10 May 2008) | 4 lines
  Copied two versions of the example from the interactive session.  Delete
  one.
........
  r63037 | georg.brandl | 2008-05-11 03:02:17 -0400 (Sun, 11 May 2008) | 2 lines
  reload() takes the module itself.
........
  r63038 | alexandre.vassalotti | 2008-05-11 03:06:04 -0400 (Sun, 11 May 2008) | 4 lines
  Added test framework for handling module renames.
  Factored the import guard in test_py3kwarn.TestStdlibRemovals into
  a context manager, namely test_support.CleanImport.
........
  r63039 | georg.brandl | 2008-05-11 03:06:05 -0400 (Sun, 11 May 2008) | 2 lines
  #2742: ``''`` is not converted to NULL in getaddrinfo.
........
  r63040 | alexandre.vassalotti | 2008-05-11 03:08:12 -0400 (Sun, 11 May 2008) | 2 lines
  Fixed typo in a comment of test_support.CleanImport.
........
  r63041 | alexandre.vassalotti | 2008-05-11 03:10:25 -0400 (Sun, 11 May 2008) | 2 lines
  Removed a dead line of code.
........
  r63043 | georg.brandl | 2008-05-11 04:47:53 -0400 (Sun, 11 May 2008) | 2 lines
  #2812: document property.getter/setter/deleter.
........
  r63049 | georg.brandl | 2008-05-11 05:06:30 -0400 (Sun, 11 May 2008) | 2 lines
  #1153769: document PEP 237 changes to string formatting.
........
  r63050 | georg.brandl | 2008-05-11 05:11:40 -0400 (Sun, 11 May 2008) | 2 lines
  #2809: elaborate str.split docstring a bit.
........
  r63051 | georg.brandl | 2008-05-11 06:13:59 -0400 (Sun, 11 May 2008) | 2 lines
  Fix typo.
........
  r63052 | georg.brandl | 2008-05-11 06:33:27 -0400 (Sun, 11 May 2008) | 2 lines
  #2709: clarification.
........
  r63053 | georg.brandl | 2008-05-11 06:42:28 -0400 (Sun, 11 May 2008) | 2 lines
  #2659: add ``break_on_hyphens`` to TextWrapper.
........
  r63057 | georg.brandl | 2008-05-11 06:59:39 -0400 (Sun, 11 May 2008) | 2 lines
  #2741: clarification of value range for address_family.
........
  r63058 | georg.brandl | 2008-05-11 07:09:35 -0400 (Sun, 11 May 2008) | 2 lines
  #2452: timeout is used for all blocking operations.
........
  r63059 | andrew.kuchling | 2008-05-11 09:33:56 -0400 (Sun, 11 May 2008) | 2 lines
  #1792: Improve performance of marshal.dumps() on large objects by increasing
  the size of the buffer more quickly.
........
  r63060 | andrew.kuchling | 2008-05-11 10:00:00 -0400 (Sun, 11 May 2008) | 1 line
  #1858: re-apply patch for this, adding the missing files
........
  r63061 | benjamin.peterson | 2008-05-11 10:13:25 -0400 (Sun, 11 May 2008) | 2 lines
  Add the "until" command to pdb
........
  r63062 | georg.brandl | 2008-05-11 10:17:13 -0400 (Sun, 11 May 2008) | 2 lines
  Add some sentence endings.
........
											
										 
											2008-05-16 00:03:33 +00:00
										 |  |  |    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
 | 
					
						
							| 
									
										
										
										
											2013-06-23 15:47:50 -04:00
										 |  |  |    *port* is zero, the standard SMTP-over-SSL port (465) is used.  The optional
 | 
					
						
							| 
									
										
										
										
											2014-03-22 18:19:11 +01:00
										 |  |  |    arguments *local_hostname*, *timeout* and *source_address* have the same
 | 
					
						
							|  |  |  |    meaning as they do in the :class:`SMTP` class.  *context*, also optional,
 | 
					
						
							| 
									
										
										
										
											2016-02-10 05:44:01 +00:00
										 |  |  |    can contain a :class:`~ssl.SSLContext` and allows configuring various
 | 
					
						
							| 
									
										
										
										
											2014-03-22 18:19:11 +01:00
										 |  |  |    aspects of the secure connection.  Please read :ref:`ssl-security` for
 | 
					
						
							|  |  |  |    best practices.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    *keyfile* and *certfile* are a legacy alternative to *context*, and can
 | 
					
						
							|  |  |  |    point to a PEM formatted private key and certificate chain file for the
 | 
					
						
							|  |  |  |    SSL connection.
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-18 18:03:09 +02:00
										 |  |  |    .. versionchanged:: 3.3
 | 
					
						
							|  |  |  |       *context* was added.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-31 09:14:17 +08:00
										 |  |  |    .. versionchanged:: 3.3
 | 
					
						
							|  |  |  |       source_address argument was added.
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-02 20:44:17 +01:00
										 |  |  |    .. versionchanged:: 3.4
 | 
					
						
							|  |  |  |       The class now supports hostname check with
 | 
					
						
							| 
									
										
										
										
											2014-03-22 18:19:11 +01:00
										 |  |  |       :attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
 | 
					
						
							|  |  |  |       :data:`ssl.HAS_SNI`).
 | 
					
						
							| 
									
										
										
										
											2011-07-30 10:56:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-10 23:23:33 +02:00
										 |  |  |    .. deprecated:: 3.6
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |        *keyfile* and *certfile* are deprecated in favor of *context*.
 | 
					
						
							|  |  |  |        Please use :meth:`ssl.SSLContext.load_cert_chain` instead, or let
 | 
					
						
							|  |  |  |        :func:`ssl.create_default_context` select the system's trusted CA
 | 
					
						
							|  |  |  |        certificates for you.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-30 10:56:50 +08:00
										 |  |  | .. class:: LMTP(host='', port=LMTP_PORT, local_hostname=None, source_address=None)
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    The LMTP protocol, which is very similar to ESMTP, is heavily based on the
 | 
					
						
							| 
									
										
										
										
											2011-07-30 10:56:50 +08:00
										 |  |  |    standard SMTP client. It's common to use Unix sockets for LMTP, so our
 | 
					
						
							|  |  |  |    :meth:`connect` method must support that as well as a regular host:port
 | 
					
						
							| 
									
										
										
										
											2011-07-31 09:14:17 +08:00
										 |  |  |    server. The optional arguments local_hostname and source_address have the
 | 
					
						
							| 
									
										
										
										
											2013-06-23 16:05:44 -04:00
										 |  |  |    same meaning as they do in the :class:`SMTP` class. To specify a Unix
 | 
					
						
							|  |  |  |    socket, you must use an absolute path for *host*, starting with a '/'.
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-23 16:05:44 -04:00
										 |  |  |    Authentication is supported, using the regular SMTP mechanism. When using a
 | 
					
						
							|  |  |  |    Unix socket, LMTP generally don't support or require any authentication, but
 | 
					
						
							|  |  |  |    your mileage might vary.
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | A nice selection of exceptions is defined as well:
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. exception:: SMTPException
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-14 06:46:35 -04:00
										 |  |  |    Subclass of :exc:`OSError` that is the base exception class for all
 | 
					
						
							| 
									
										
										
										
											2013-08-13 01:15:14 -07:00
										 |  |  |    the other exceptions provided by this module.
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-15 21:13:56 -07:00
										 |  |  |    .. versionchanged:: 3.4
 | 
					
						
							|  |  |  |       SMTPException became subclass of :exc:`OSError`
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | .. exception:: SMTPServerDisconnected
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This exception is raised when the server unexpectedly disconnects, or when an
 | 
					
						
							|  |  |  |    attempt is made to use the :class:`SMTP` instance before connecting it to a
 | 
					
						
							|  |  |  |    server.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. exception:: SMTPResponseException
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Base class for all exceptions that include an SMTP error code. These exceptions
 | 
					
						
							|  |  |  |    are generated in some instances when the SMTP server returns an error code.  The
 | 
					
						
							|  |  |  |    error code is stored in the :attr:`smtp_code` attribute of the error, and the
 | 
					
						
							|  |  |  |    :attr:`smtp_error` attribute is set to the error message.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. exception:: SMTPSenderRefused
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Sender address refused.  In addition to the attributes set by on all
 | 
					
						
							|  |  |  |    :exc:`SMTPResponseException` exceptions, this sets 'sender' to the string that
 | 
					
						
							|  |  |  |    the SMTP server refused.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. exception:: SMTPRecipientsRefused
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    All recipient addresses refused.  The errors for each recipient are accessible
 | 
					
						
							|  |  |  |    through the attribute :attr:`recipients`, which is a dictionary of exactly the
 | 
					
						
							|  |  |  |    same sort as :meth:`SMTP.sendmail` returns.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. exception:: SMTPDataError
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    The SMTP server refused to accept the message data.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. exception:: SMTPConnectError
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Error occurred during establishment of a connection  with the server.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. exception:: SMTPHeloError
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    The server refused our ``HELO`` message.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-16 13:58:14 -04:00
										 |  |  | .. exception:: SMTPNotSupportedError
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     The command or option attempted is not supported by the server.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     .. versionadded:: 3.5
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | .. exception:: SMTPAuthenticationError
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    SMTP authentication went wrong.  Most probably the server didn't accept the
 | 
					
						
							|  |  |  |    username/password combination provided.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. seealso::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    :rfc:`821` - Simple Mail Transfer Protocol
 | 
					
						
							|  |  |  |       Protocol definition for SMTP.  This document covers the model, operating
 | 
					
						
							|  |  |  |       procedure, and protocol details for SMTP.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    :rfc:`1869` - SMTP Service Extensions
 | 
					
						
							|  |  |  |       Definition of the ESMTP extensions for SMTP.  This describes a framework for
 | 
					
						
							|  |  |  |       extending SMTP with new commands, supporting dynamic discovery of the commands
 | 
					
						
							|  |  |  |       provided by the server, and defines a few additional commands.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. _smtp-objects:
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SMTP Objects
 | 
					
						
							|  |  |  | ------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | An :class:`SMTP` instance has the following methods:
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. method:: SMTP.set_debuglevel(level)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-16 17:24:52 -04:00
										 |  |  |    Set the debug output level.  A value of 1 or ``True`` for *level* results in
 | 
					
						
							|  |  |  |    debug messages for connection and for all messages sent to and received from
 | 
					
						
							|  |  |  |    the server.  A value of 2 for *level* results in these messages being
 | 
					
						
							|  |  |  |    timestamped.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    .. versionchanged:: 3.5 Added debuglevel 2.
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-02 20:34:52 +00:00
										 |  |  | .. method:: SMTP.docmd(cmd, args='')
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-02 20:34:52 +00:00
										 |  |  |    Send a command *cmd* to the server.  The optional argument *args* is simply
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  |    concatenated to the command, separated by a space.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This returns a 2-tuple composed of a numeric response code and the actual
 | 
					
						
							|  |  |  |    response line (multiline responses are joined into one long line.)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    In normal operation it should not be necessary to call this method explicitly.
 | 
					
						
							|  |  |  |    It is used to implement other methods and may be useful for testing private
 | 
					
						
							|  |  |  |    extensions.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    If the connection to the server is lost while waiting for the reply,
 | 
					
						
							|  |  |  |    :exc:`SMTPServerDisconnected` will be raised.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 14:40:33 -04:00
										 |  |  | .. 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.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-02 20:34:52 +00:00
										 |  |  | .. method:: SMTP.helo(name='')
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    Identify yourself to the SMTP server using ``HELO``.  The hostname argument
 | 
					
						
							|  |  |  |    defaults to the fully qualified domain name of the local host.
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
  Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
  library targets in the Makefile.
........
  r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
  Add quotes around the file name to avoid issues with spaces.
  Closes #3719.
........
  r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
  Add news item for #3719.
........
  r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
  Issue #3726: Allowed spaces in separators in logging configuration files.
........
  r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
  Issue #3772: Fixed regression problem in StreamHandler.emit().
........
  r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
  #3671: various corrections and markup fixes noted by Kent Johnson
........
  r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
  Added NEWS
........
  r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
  flesh out the documentation on using 2to3
........
  r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
  #3671: Typo fix
........
  r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
  Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
  r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
  actually tell the name of the flag to use
........
  r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
  Various corrections
........
  r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
  #3040: include 'dest' argument in example; trim some trailing whitespace
........
  r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
  docs are pretty good about new-style classes these days
........
  r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
  #3669 from Robert Lehmann: simplify use of iterator in example
........
  r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
  #1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
  r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
  Add a new howto about Python and the web, by Marek Kubica.
........
  r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
  Added xrefs to each other.
........
											
										 
											2008-09-08 23:05:23 +00:00
										 |  |  |    The message returned by the server is stored as the :attr:`helo_resp` attribute
 | 
					
						
							|  |  |  |    of the object.
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    In normal operation it should not be necessary to call this method explicitly.
 | 
					
						
							|  |  |  |    It will be implicitly called by the :meth:`sendmail` when necessary.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-02 20:34:52 +00:00
										 |  |  | .. method:: SMTP.ehlo(name='')
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    Identify yourself to an ESMTP server using ``EHLO``.  The hostname argument
 | 
					
						
							|  |  |  |    defaults to the fully qualified domain name of the local host.  Examine the
 | 
					
						
							| 
									
										
										
										
											2009-01-03 21:18:54 +00:00
										 |  |  |    response for ESMTP option and store them for use by :meth:`has_extn`.
 | 
					
						
							|  |  |  |    Also sets several informational attributes: the message returned by
 | 
					
						
							|  |  |  |    the server is stored as the :attr:`ehlo_resp` attribute, :attr:`does_esmtp`
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
  Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
  library targets in the Makefile.
........
  r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
  Add quotes around the file name to avoid issues with spaces.
  Closes #3719.
........
  r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
  Add news item for #3719.
........
  r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
  Issue #3726: Allowed spaces in separators in logging configuration files.
........
  r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
  Issue #3772: Fixed regression problem in StreamHandler.emit().
........
  r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
  #3671: various corrections and markup fixes noted by Kent Johnson
........
  r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
  Added NEWS
........
  r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
  flesh out the documentation on using 2to3
........
  r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
  #3671: Typo fix
........
  r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
  Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
  r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
  actually tell the name of the flag to use
........
  r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
  Various corrections
........
  r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
  #3040: include 'dest' argument in example; trim some trailing whitespace
........
  r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
  docs are pretty good about new-style classes these days
........
  r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
  #3669 from Robert Lehmann: simplify use of iterator in example
........
  r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
  #1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
  r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
  Add a new howto about Python and the web, by Marek Kubica.
........
  r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
  Added xrefs to each other.
........
											
										 
											2008-09-08 23:05:23 +00:00
										 |  |  |    is set to true or false depending on whether the server supports ESMTP, and
 | 
					
						
							|  |  |  |    :attr:`esmtp_features` will be a dictionary containing the names of the
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:47:46 -04:00
										 |  |  |    SMTP service extensions this server supports, and their parameters (if any).
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    Unless you wish to use :meth:`has_extn` before sending mail, it should not be
 | 
					
						
							|  |  |  |    necessary to call this method explicitly.  It will be implicitly called by
 | 
					
						
							|  |  |  |    :meth:`sendmail` when necessary.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 59985-60000,60002,60005-60007,60009-60042 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r59987 | raymond.hettinger | 2008-01-15 21:52:42 +0100 (Tue, 15 Jan 2008) | 1 line
  Refactor if/elif chain for clarity and speed.  Remove dependency on subclasses having to implement _empty and _full.
........
  r59988 | raymond.hettinger | 2008-01-15 22:22:47 +0100 (Tue, 15 Jan 2008) | 1 line
  Fix-up half-written paragraph in the docs
........
  r59989 | amaury.forgeotdarc | 2008-01-15 22:25:11 +0100 (Tue, 15 Jan 2008) | 3 lines
  test_doctest fails since r59984.
  Not sure if these are the correct values, but save_stdout has to be set before its usage...
........
  r59992 | andrew.kuchling | 2008-01-16 01:32:03 +0100 (Wed, 16 Jan 2008) | 1 line
  Docstring typos
........
  r59993 | andrew.kuchling | 2008-01-16 04:17:25 +0100 (Wed, 16 Jan 2008) | 1 line
  Add PEP 3141 section
........
  r59998 | andrew.kuchling | 2008-01-16 14:01:51 +0100 (Wed, 16 Jan 2008) | 1 line
  Markup fix
........
  r59999 | georg.brandl | 2008-01-16 17:56:29 +0100 (Wed, 16 Jan 2008) | 2 lines
  Fix MSDN library URL. (#1854)
........
  r60006 | georg.brandl | 2008-01-16 21:27:56 +0100 (Wed, 16 Jan 2008) | 3 lines
  Add Python-specific content to Doc dir. Update configuration file
  to work with the newest Sphinx.
........
  r60007 | georg.brandl | 2008-01-16 21:29:00 +0100 (Wed, 16 Jan 2008) | 2 lines
  Doc build should work with 2.4 now.
........
  r60009 | raymond.hettinger | 2008-01-17 00:38:16 +0100 (Thu, 17 Jan 2008) | 1 line
  Minor wordsmithing.
........
  r60010 | raymond.hettinger | 2008-01-17 00:40:45 +0100 (Thu, 17 Jan 2008) | 1 line
  Add queues will alternative fetch orders (priority based and stack based).
........
  r60011 | raymond.hettinger | 2008-01-17 00:49:35 +0100 (Thu, 17 Jan 2008) | 1 line
  Add news entry.
........
  r60013 | raymond.hettinger | 2008-01-17 04:02:14 +0100 (Thu, 17 Jan 2008) | 1 line
  Make starmap() match its pure python definition and accept any itertable input (not just tuples).
........
  r60015 | gregory.p.smith | 2008-01-17 08:43:20 +0100 (Thu, 17 Jan 2008) | 3 lines
  Comply with RFC 3207.
  Fixes issue 829951 - http://bugs.python.org/issue829951
........
  r60018 | gregory.p.smith | 2008-01-17 09:03:17 +0100 (Thu, 17 Jan 2008) | 2 lines
  entry for r60015
........
  r60019 | raymond.hettinger | 2008-01-17 09:07:05 +0100 (Thu, 17 Jan 2008) | 1 line
  Note versionadded.
........
  r60020 | gregory.p.smith | 2008-01-17 09:35:49 +0100 (Thu, 17 Jan 2008) | 8 lines
  Fixes (accepts patch) issue1339 - http://bugs.python.org/issue1339
  - Factor out the duplication of EHLO/HELO in login() and sendmail() to
    a new function, ehlo_or_helo_if_needed().
  - Use ehlo_or_helo_if_needed() in starttls()
  - Check for the starttls exception in starttls() in the same way as
    login() checks for the auth extension.
  Contributed by Bill Fenner.
........
  r60021 | andrew.kuchling | 2008-01-17 13:00:15 +0100 (Thu, 17 Jan 2008) | 1 line
  Revise 3141 section a bit; add some Windows items
........
  r60022 | brett.cannon | 2008-01-17 19:45:10 +0100 (Thu, 17 Jan 2008) | 2 lines
  Fix a function pointer declaration to silence the compiler.
........
  r60024 | raymond.hettinger | 2008-01-17 20:31:38 +0100 (Thu, 17 Jan 2008) | 1 line
  Issue #1861:  Add read-only attribute listing upcoming events in the order they will be run.
........
  r60025 | andrew.kuchling | 2008-01-17 20:49:24 +0100 (Thu, 17 Jan 2008) | 1 line
  Correction from Jordan Lewis: halfdelay() uses tenths of a second, not milliseconds
........
  r60026 | raymond.hettinger | 2008-01-17 23:27:49 +0100 (Thu, 17 Jan 2008) | 1 line
  Add advice on choosing between scheduler and threading.Timer().
........
  r60028 | christian.heimes | 2008-01-18 00:01:44 +0100 (Fri, 18 Jan 2008) | 2 lines
  Updated new property syntax. An elaborate example for subclassing and the getter was missing.
  Added comment about VS 2008 and PGO builds.
........
  r60029 | raymond.hettinger | 2008-01-18 00:32:01 +0100 (Fri, 18 Jan 2008) | 1 line
  Fix-up Timer() example.
........
  r60030 | raymond.hettinger | 2008-01-18 00:56:56 +0100 (Fri, 18 Jan 2008) | 1 line
  Fix markup
........
  r60031 | raymond.hettinger | 2008-01-18 01:10:42 +0100 (Fri, 18 Jan 2008) | 1 line
  clearcache() needs to remove the dict as well as clear it.
........
  r60033 | andrew.kuchling | 2008-01-18 03:26:16 +0100 (Fri, 18 Jan 2008) | 1 line
  Bump verson
........
  r60034 | andrew.kuchling | 2008-01-18 03:42:52 +0100 (Fri, 18 Jan 2008) | 1 line
  Typo fix
........
  r60035 | christian.heimes | 2008-01-18 08:30:20 +0100 (Fri, 18 Jan 2008) | 3 lines
  Coverity issue CID #197
  var_decl: Declared variable "stm" without initializer
  ninit_use_in_call: Using uninitialized value "stm" (field "stm".tm_zone uninitialized) in call to function "mktime"
........
  r60036 | christian.heimes | 2008-01-18 08:45:30 +0100 (Fri, 18 Jan 2008) | 11 lines
  Coverity issue CID #167
  Event alloc_fn: Called allocation function "metacompile" [model]
  Event var_assign: Assigned variable "gr" to storage returned from "metacompile"
  		gr = metacompile(n);
  Event pass_arg: Variable "gr" not freed or pointed-to in function "maketables" [model]
  		g = maketables(gr);
    		translatelabels(g);
    		addfirstsets(g);
  Event leaked_storage: Returned without freeing storage "gr"
  		return g;
........
  r60038 | christian.heimes | 2008-01-18 09:04:57 +0100 (Fri, 18 Jan 2008) | 3 lines
  Coverity issue CID #182
  size_error: Allocating 1 bytes to pointer "children", which needs at least 4 bytes
........
  r60041 | christian.heimes | 2008-01-18 09:47:59 +0100 (Fri, 18 Jan 2008) | 4 lines
  Coverity issue CID #169
  local_ptr_assign_local: Assigning address of stack variable "namebuf" to pointer "filename"
  out_of_scope: Variable "namebuf" goes out of scope
  use_invalid: Used "filename" pointing to out-of-scope variable "namebuf"
........
  r60042 | christian.heimes | 2008-01-18 09:53:45 +0100 (Fri, 18 Jan 2008) | 2 lines
  Coverity CID #168
  leaked_storage: Returned without freeing storage "fp"
........
											
										 
											2008-01-18 09:56:22 +00:00
										 |  |  | .. method:: SMTP.ehlo_or_helo_if_needed()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This method call :meth:`ehlo` and or :meth:`helo` if there has been no
 | 
					
						
							|  |  |  |    previous ``EHLO`` or ``HELO`` command this session.  It tries ESMTP ``EHLO``
 | 
					
						
							|  |  |  |    first.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 68162,68166,68171,68176,68195-68196,68210,68232 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r68162 | ronald.oussoren | 2009-01-02 16:06:00 +0100 (Fri, 02 Jan 2009) | 3 lines
  Fix for issue 4472 is incompatible with Cygwin, this patch
  should fix that.
........
  r68166 | benjamin.peterson | 2009-01-02 19:26:23 +0100 (Fri, 02 Jan 2009) | 1 line
  document PyMemberDef
........
  r68171 | georg.brandl | 2009-01-02 21:25:14 +0100 (Fri, 02 Jan 2009) | 3 lines
  #4811: fix markup glitches (mostly remains of the conversion),
  found by Gabriel Genellina.
........
  r68176 | andrew.kuchling | 2009-01-02 22:00:35 +0100 (Fri, 02 Jan 2009) | 1 line
  Add various items
........
  r68195 | georg.brandl | 2009-01-03 14:45:15 +0100 (Sat, 03 Jan 2009) | 2 lines
  Remove useless string literal.
........
  r68196 | georg.brandl | 2009-01-03 15:29:53 +0100 (Sat, 03 Jan 2009) | 2 lines
  Fix indentation.
........
  r68210 | georg.brandl | 2009-01-03 20:10:12 +0100 (Sat, 03 Jan 2009) | 2 lines
  Set eol-style correctly for mp_distributing.py.
........
  r68232 | georg.brandl | 2009-01-03 22:52:16 +0100 (Sat, 03 Jan 2009) | 2 lines
  Grammar fix.
........
											
										 
											2009-01-03 22:47:39 +00:00
										 |  |  |    :exc:`SMTPHeloError`
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 59985-60000,60002,60005-60007,60009-60042 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r59987 | raymond.hettinger | 2008-01-15 21:52:42 +0100 (Tue, 15 Jan 2008) | 1 line
  Refactor if/elif chain for clarity and speed.  Remove dependency on subclasses having to implement _empty and _full.
........
  r59988 | raymond.hettinger | 2008-01-15 22:22:47 +0100 (Tue, 15 Jan 2008) | 1 line
  Fix-up half-written paragraph in the docs
........
  r59989 | amaury.forgeotdarc | 2008-01-15 22:25:11 +0100 (Tue, 15 Jan 2008) | 3 lines
  test_doctest fails since r59984.
  Not sure if these are the correct values, but save_stdout has to be set before its usage...
........
  r59992 | andrew.kuchling | 2008-01-16 01:32:03 +0100 (Wed, 16 Jan 2008) | 1 line
  Docstring typos
........
  r59993 | andrew.kuchling | 2008-01-16 04:17:25 +0100 (Wed, 16 Jan 2008) | 1 line
  Add PEP 3141 section
........
  r59998 | andrew.kuchling | 2008-01-16 14:01:51 +0100 (Wed, 16 Jan 2008) | 1 line
  Markup fix
........
  r59999 | georg.brandl | 2008-01-16 17:56:29 +0100 (Wed, 16 Jan 2008) | 2 lines
  Fix MSDN library URL. (#1854)
........
  r60006 | georg.brandl | 2008-01-16 21:27:56 +0100 (Wed, 16 Jan 2008) | 3 lines
  Add Python-specific content to Doc dir. Update configuration file
  to work with the newest Sphinx.
........
  r60007 | georg.brandl | 2008-01-16 21:29:00 +0100 (Wed, 16 Jan 2008) | 2 lines
  Doc build should work with 2.4 now.
........
  r60009 | raymond.hettinger | 2008-01-17 00:38:16 +0100 (Thu, 17 Jan 2008) | 1 line
  Minor wordsmithing.
........
  r60010 | raymond.hettinger | 2008-01-17 00:40:45 +0100 (Thu, 17 Jan 2008) | 1 line
  Add queues will alternative fetch orders (priority based and stack based).
........
  r60011 | raymond.hettinger | 2008-01-17 00:49:35 +0100 (Thu, 17 Jan 2008) | 1 line
  Add news entry.
........
  r60013 | raymond.hettinger | 2008-01-17 04:02:14 +0100 (Thu, 17 Jan 2008) | 1 line
  Make starmap() match its pure python definition and accept any itertable input (not just tuples).
........
  r60015 | gregory.p.smith | 2008-01-17 08:43:20 +0100 (Thu, 17 Jan 2008) | 3 lines
  Comply with RFC 3207.
  Fixes issue 829951 - http://bugs.python.org/issue829951
........
  r60018 | gregory.p.smith | 2008-01-17 09:03:17 +0100 (Thu, 17 Jan 2008) | 2 lines
  entry for r60015
........
  r60019 | raymond.hettinger | 2008-01-17 09:07:05 +0100 (Thu, 17 Jan 2008) | 1 line
  Note versionadded.
........
  r60020 | gregory.p.smith | 2008-01-17 09:35:49 +0100 (Thu, 17 Jan 2008) | 8 lines
  Fixes (accepts patch) issue1339 - http://bugs.python.org/issue1339
  - Factor out the duplication of EHLO/HELO in login() and sendmail() to
    a new function, ehlo_or_helo_if_needed().
  - Use ehlo_or_helo_if_needed() in starttls()
  - Check for the starttls exception in starttls() in the same way as
    login() checks for the auth extension.
  Contributed by Bill Fenner.
........
  r60021 | andrew.kuchling | 2008-01-17 13:00:15 +0100 (Thu, 17 Jan 2008) | 1 line
  Revise 3141 section a bit; add some Windows items
........
  r60022 | brett.cannon | 2008-01-17 19:45:10 +0100 (Thu, 17 Jan 2008) | 2 lines
  Fix a function pointer declaration to silence the compiler.
........
  r60024 | raymond.hettinger | 2008-01-17 20:31:38 +0100 (Thu, 17 Jan 2008) | 1 line
  Issue #1861:  Add read-only attribute listing upcoming events in the order they will be run.
........
  r60025 | andrew.kuchling | 2008-01-17 20:49:24 +0100 (Thu, 17 Jan 2008) | 1 line
  Correction from Jordan Lewis: halfdelay() uses tenths of a second, not milliseconds
........
  r60026 | raymond.hettinger | 2008-01-17 23:27:49 +0100 (Thu, 17 Jan 2008) | 1 line
  Add advice on choosing between scheduler and threading.Timer().
........
  r60028 | christian.heimes | 2008-01-18 00:01:44 +0100 (Fri, 18 Jan 2008) | 2 lines
  Updated new property syntax. An elaborate example for subclassing and the getter was missing.
  Added comment about VS 2008 and PGO builds.
........
  r60029 | raymond.hettinger | 2008-01-18 00:32:01 +0100 (Fri, 18 Jan 2008) | 1 line
  Fix-up Timer() example.
........
  r60030 | raymond.hettinger | 2008-01-18 00:56:56 +0100 (Fri, 18 Jan 2008) | 1 line
  Fix markup
........
  r60031 | raymond.hettinger | 2008-01-18 01:10:42 +0100 (Fri, 18 Jan 2008) | 1 line
  clearcache() needs to remove the dict as well as clear it.
........
  r60033 | andrew.kuchling | 2008-01-18 03:26:16 +0100 (Fri, 18 Jan 2008) | 1 line
  Bump verson
........
  r60034 | andrew.kuchling | 2008-01-18 03:42:52 +0100 (Fri, 18 Jan 2008) | 1 line
  Typo fix
........
  r60035 | christian.heimes | 2008-01-18 08:30:20 +0100 (Fri, 18 Jan 2008) | 3 lines
  Coverity issue CID #197
  var_decl: Declared variable "stm" without initializer
  ninit_use_in_call: Using uninitialized value "stm" (field "stm".tm_zone uninitialized) in call to function "mktime"
........
  r60036 | christian.heimes | 2008-01-18 08:45:30 +0100 (Fri, 18 Jan 2008) | 11 lines
  Coverity issue CID #167
  Event alloc_fn: Called allocation function "metacompile" [model]
  Event var_assign: Assigned variable "gr" to storage returned from "metacompile"
  		gr = metacompile(n);
  Event pass_arg: Variable "gr" not freed or pointed-to in function "maketables" [model]
  		g = maketables(gr);
    		translatelabels(g);
    		addfirstsets(g);
  Event leaked_storage: Returned without freeing storage "gr"
  		return g;
........
  r60038 | christian.heimes | 2008-01-18 09:04:57 +0100 (Fri, 18 Jan 2008) | 3 lines
  Coverity issue CID #182
  size_error: Allocating 1 bytes to pointer "children", which needs at least 4 bytes
........
  r60041 | christian.heimes | 2008-01-18 09:47:59 +0100 (Fri, 18 Jan 2008) | 4 lines
  Coverity issue CID #169
  local_ptr_assign_local: Assigning address of stack variable "namebuf" to pointer "filename"
  out_of_scope: Variable "namebuf" goes out of scope
  use_invalid: Used "filename" pointing to out-of-scope variable "namebuf"
........
  r60042 | christian.heimes | 2008-01-18 09:53:45 +0100 (Fri, 18 Jan 2008) | 2 lines
  Coverity CID #168
  leaked_storage: Returned without freeing storage "fp"
........
											
										 
											2008-01-18 09:56:22 +00:00
										 |  |  |      The server didn't reply properly to the ``HELO`` greeting.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | .. method:: SMTP.has_extn(name)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Return :const:`True` if *name* is in the set of SMTP service extensions returned
 | 
					
						
							|  |  |  |    by the server, :const:`False` otherwise. Case is ignored.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. method:: SMTP.verify(address)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Check the validity of an address on this server using SMTP ``VRFY``. Returns a
 | 
					
						
							|  |  |  |    tuple consisting of code 250 and a full :rfc:`822` address (including human
 | 
					
						
							|  |  |  |    name) if the user address is valid. Otherwise returns an SMTP error code of 400
 | 
					
						
							|  |  |  |    or greater and an error string.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    .. note::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       Many sites disable SMTP ``VRFY`` in order to foil spammers.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-09 10:39:55 -04:00
										 |  |  | .. method:: SMTP.login(user, password, *, initial_response_ok=True)
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    Log in on an SMTP server that requires authentication. The arguments are the
 | 
					
						
							|  |  |  |    username and the password to authenticate with. If there has been no previous
 | 
					
						
							|  |  |  |    ``EHLO`` or ``HELO`` command this session, this method tries ESMTP ``EHLO``
 | 
					
						
							|  |  |  |    first. This method will return normally if the authentication was successful, or
 | 
					
						
							|  |  |  |    may raise the following exceptions:
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    :exc:`SMTPHeloError`
 | 
					
						
							|  |  |  |       The server didn't reply properly to the ``HELO`` greeting.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    :exc:`SMTPAuthenticationError`
 | 
					
						
							|  |  |  |       The server didn't accept the username/password combination.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-16 13:58:14 -04:00
										 |  |  |    :exc:`SMTPNotSupportedError`
 | 
					
						
							|  |  |  |       The ``AUTH`` command is not supported by the server.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  |    :exc:`SMTPException`
 | 
					
						
							|  |  |  |       No suitable authentication method was found.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:47:46 -04:00
										 |  |  |    Each of the authentication methods supported by :mod:`smtplib` are tried in
 | 
					
						
							| 
									
										
										
										
											2015-07-09 10:39:55 -04:00
										 |  |  |    turn if they are advertised as supported by the server.  See :meth:`auth`
 | 
					
						
							|  |  |  |    for a list of supported authentication methods.  *initial_response_ok* is
 | 
					
						
							|  |  |  |    passed through to :meth:`auth`.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Optional keyword argument *initial_response_ok* specifies whether, for
 | 
					
						
							|  |  |  |    authentication methods that support it, an "initial response" as specified
 | 
					
						
							|  |  |  |    in :rfc:`4954` can be sent along with the ``AUTH`` command, rather than
 | 
					
						
							|  |  |  |    requiring a challenge/response.
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:47:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-16 13:58:14 -04:00
										 |  |  |    .. versionchanged:: 3.5
 | 
					
						
							| 
									
										
										
										
											2015-07-09 10:39:55 -04:00
										 |  |  |       :exc:`SMTPNotSupportedError` may be raised, and the
 | 
					
						
							|  |  |  |       *initial_response_ok* parameter was added.
 | 
					
						
							| 
									
										
										
										
											2015-05-16 13:58:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:47:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-09 10:39:55 -04:00
										 |  |  | .. method:: SMTP.auth(mechanism, authobject, *, initial_response_ok=True)
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:47:46 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |    Issue an ``SMTP`` ``AUTH`` command for the specified authentication
 | 
					
						
							|  |  |  |    *mechanism*, and handle the challenge response via *authobject*.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    *mechanism* specifies which authentication mechanism is to
 | 
					
						
							|  |  |  |    be used as argument to the ``AUTH`` command; the valid values are
 | 
					
						
							|  |  |  |    those listed in the ``auth`` element of :attr:`esmtp_features`.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-09 10:39:55 -04:00
										 |  |  |    *authobject* must be a callable object taking an optional single argument:
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |      data = authobject(challenge=None)
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:47:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-09 10:39:55 -04:00
										 |  |  |    If optional keyword argument *initial_response_ok* is true,
 | 
					
						
							|  |  |  |    ``authobject()`` will be called first with no argument.  It can return the
 | 
					
						
							|  |  |  |    :rfc:`4954` "initial response" bytes which will be encoded and sent with
 | 
					
						
							|  |  |  |    the ``AUTH`` command as below.  If the ``authobject()`` does not support an
 | 
					
						
							|  |  |  |    initial response (e.g. because it requires a challenge), it should return
 | 
					
						
							| 
									
										
										
										
											2016-10-19 16:29:26 +03:00
										 |  |  |    ``None`` when called with ``challenge=None``.  If *initial_response_ok* is
 | 
					
						
							|  |  |  |    false, then ``authobject()`` will not be called first with ``None``.
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:47:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-19 16:29:26 +03:00
										 |  |  |    If the initial response check returns ``None``, or if *initial_response_ok* is
 | 
					
						
							| 
									
										
										
										
											2015-07-09 10:39:55 -04:00
										 |  |  |    false, ``authobject()`` will be called to process the server's challenge
 | 
					
						
							|  |  |  |    response; the *challenge* argument it is passed will be a ``bytes``.  It
 | 
					
						
							|  |  |  |    should return ``bytes`` *data* that will be base64 encoded and sent to the
 | 
					
						
							|  |  |  |    server.
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:47:46 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |    The ``SMTP`` class provides ``authobjects`` for the ``CRAM-MD5``, ``PLAIN``,
 | 
					
						
							|  |  |  |    and ``LOGIN`` mechanisms; they are named ``SMTP.auth_cram_md5``,
 | 
					
						
							|  |  |  |    ``SMTP.auth_plain``, and ``SMTP.auth_login`` respectively.  They all require
 | 
					
						
							|  |  |  |    that the ``user`` and ``password`` properties of the ``SMTP`` instance are
 | 
					
						
							|  |  |  |    set to appropriate values.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    User code does not normally need to call ``auth`` directly, but can instead
 | 
					
						
							| 
									
										
										
										
											2015-07-09 10:39:55 -04:00
										 |  |  |    call the :meth:`login` method, which will try each of the above mechanisms
 | 
					
						
							|  |  |  |    in turn, in the order listed.  ``auth`` is exposed to facilitate the
 | 
					
						
							|  |  |  |    implementation of authentication methods not (or not yet) supported
 | 
					
						
							|  |  |  |    directly by :mod:`smtplib`.
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:47:46 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |    .. versionadded:: 3.5
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-18 18:03:09 +02:00
										 |  |  | .. method:: SMTP.starttls(keyfile=None, certfile=None, context=None)
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    Put the SMTP connection in TLS (Transport Layer Security) mode.  All SMTP
 | 
					
						
							|  |  |  |    commands that follow will be encrypted.  You should then call :meth:`ehlo`
 | 
					
						
							|  |  |  |    again.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    If *keyfile* and *certfile* are provided, these are passed to the :mod:`socket`
 | 
					
						
							|  |  |  |    module's :func:`ssl` function.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-19 16:29:26 +03:00
										 |  |  |    Optional *context* parameter is a :class:`ssl.SSLContext` object; This is
 | 
					
						
							|  |  |  |    an alternative to using a keyfile and a certfile and if specified both
 | 
					
						
							|  |  |  |    *keyfile* and *certfile* should be ``None``.
 | 
					
						
							| 
									
										
										
										
											2011-05-18 18:03:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 59985-60000,60002,60005-60007,60009-60042 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r59987 | raymond.hettinger | 2008-01-15 21:52:42 +0100 (Tue, 15 Jan 2008) | 1 line
  Refactor if/elif chain for clarity and speed.  Remove dependency on subclasses having to implement _empty and _full.
........
  r59988 | raymond.hettinger | 2008-01-15 22:22:47 +0100 (Tue, 15 Jan 2008) | 1 line
  Fix-up half-written paragraph in the docs
........
  r59989 | amaury.forgeotdarc | 2008-01-15 22:25:11 +0100 (Tue, 15 Jan 2008) | 3 lines
  test_doctest fails since r59984.
  Not sure if these are the correct values, but save_stdout has to be set before its usage...
........
  r59992 | andrew.kuchling | 2008-01-16 01:32:03 +0100 (Wed, 16 Jan 2008) | 1 line
  Docstring typos
........
  r59993 | andrew.kuchling | 2008-01-16 04:17:25 +0100 (Wed, 16 Jan 2008) | 1 line
  Add PEP 3141 section
........
  r59998 | andrew.kuchling | 2008-01-16 14:01:51 +0100 (Wed, 16 Jan 2008) | 1 line
  Markup fix
........
  r59999 | georg.brandl | 2008-01-16 17:56:29 +0100 (Wed, 16 Jan 2008) | 2 lines
  Fix MSDN library URL. (#1854)
........
  r60006 | georg.brandl | 2008-01-16 21:27:56 +0100 (Wed, 16 Jan 2008) | 3 lines
  Add Python-specific content to Doc dir. Update configuration file
  to work with the newest Sphinx.
........
  r60007 | georg.brandl | 2008-01-16 21:29:00 +0100 (Wed, 16 Jan 2008) | 2 lines
  Doc build should work with 2.4 now.
........
  r60009 | raymond.hettinger | 2008-01-17 00:38:16 +0100 (Thu, 17 Jan 2008) | 1 line
  Minor wordsmithing.
........
  r60010 | raymond.hettinger | 2008-01-17 00:40:45 +0100 (Thu, 17 Jan 2008) | 1 line
  Add queues will alternative fetch orders (priority based and stack based).
........
  r60011 | raymond.hettinger | 2008-01-17 00:49:35 +0100 (Thu, 17 Jan 2008) | 1 line
  Add news entry.
........
  r60013 | raymond.hettinger | 2008-01-17 04:02:14 +0100 (Thu, 17 Jan 2008) | 1 line
  Make starmap() match its pure python definition and accept any itertable input (not just tuples).
........
  r60015 | gregory.p.smith | 2008-01-17 08:43:20 +0100 (Thu, 17 Jan 2008) | 3 lines
  Comply with RFC 3207.
  Fixes issue 829951 - http://bugs.python.org/issue829951
........
  r60018 | gregory.p.smith | 2008-01-17 09:03:17 +0100 (Thu, 17 Jan 2008) | 2 lines
  entry for r60015
........
  r60019 | raymond.hettinger | 2008-01-17 09:07:05 +0100 (Thu, 17 Jan 2008) | 1 line
  Note versionadded.
........
  r60020 | gregory.p.smith | 2008-01-17 09:35:49 +0100 (Thu, 17 Jan 2008) | 8 lines
  Fixes (accepts patch) issue1339 - http://bugs.python.org/issue1339
  - Factor out the duplication of EHLO/HELO in login() and sendmail() to
    a new function, ehlo_or_helo_if_needed().
  - Use ehlo_or_helo_if_needed() in starttls()
  - Check for the starttls exception in starttls() in the same way as
    login() checks for the auth extension.
  Contributed by Bill Fenner.
........
  r60021 | andrew.kuchling | 2008-01-17 13:00:15 +0100 (Thu, 17 Jan 2008) | 1 line
  Revise 3141 section a bit; add some Windows items
........
  r60022 | brett.cannon | 2008-01-17 19:45:10 +0100 (Thu, 17 Jan 2008) | 2 lines
  Fix a function pointer declaration to silence the compiler.
........
  r60024 | raymond.hettinger | 2008-01-17 20:31:38 +0100 (Thu, 17 Jan 2008) | 1 line
  Issue #1861:  Add read-only attribute listing upcoming events in the order they will be run.
........
  r60025 | andrew.kuchling | 2008-01-17 20:49:24 +0100 (Thu, 17 Jan 2008) | 1 line
  Correction from Jordan Lewis: halfdelay() uses tenths of a second, not milliseconds
........
  r60026 | raymond.hettinger | 2008-01-17 23:27:49 +0100 (Thu, 17 Jan 2008) | 1 line
  Add advice on choosing between scheduler and threading.Timer().
........
  r60028 | christian.heimes | 2008-01-18 00:01:44 +0100 (Fri, 18 Jan 2008) | 2 lines
  Updated new property syntax. An elaborate example for subclassing and the getter was missing.
  Added comment about VS 2008 and PGO builds.
........
  r60029 | raymond.hettinger | 2008-01-18 00:32:01 +0100 (Fri, 18 Jan 2008) | 1 line
  Fix-up Timer() example.
........
  r60030 | raymond.hettinger | 2008-01-18 00:56:56 +0100 (Fri, 18 Jan 2008) | 1 line
  Fix markup
........
  r60031 | raymond.hettinger | 2008-01-18 01:10:42 +0100 (Fri, 18 Jan 2008) | 1 line
  clearcache() needs to remove the dict as well as clear it.
........
  r60033 | andrew.kuchling | 2008-01-18 03:26:16 +0100 (Fri, 18 Jan 2008) | 1 line
  Bump verson
........
  r60034 | andrew.kuchling | 2008-01-18 03:42:52 +0100 (Fri, 18 Jan 2008) | 1 line
  Typo fix
........
  r60035 | christian.heimes | 2008-01-18 08:30:20 +0100 (Fri, 18 Jan 2008) | 3 lines
  Coverity issue CID #197
  var_decl: Declared variable "stm" without initializer
  ninit_use_in_call: Using uninitialized value "stm" (field "stm".tm_zone uninitialized) in call to function "mktime"
........
  r60036 | christian.heimes | 2008-01-18 08:45:30 +0100 (Fri, 18 Jan 2008) | 11 lines
  Coverity issue CID #167
  Event alloc_fn: Called allocation function "metacompile" [model]
  Event var_assign: Assigned variable "gr" to storage returned from "metacompile"
  		gr = metacompile(n);
  Event pass_arg: Variable "gr" not freed or pointed-to in function "maketables" [model]
  		g = maketables(gr);
    		translatelabels(g);
    		addfirstsets(g);
  Event leaked_storage: Returned without freeing storage "gr"
  		return g;
........
  r60038 | christian.heimes | 2008-01-18 09:04:57 +0100 (Fri, 18 Jan 2008) | 3 lines
  Coverity issue CID #182
  size_error: Allocating 1 bytes to pointer "children", which needs at least 4 bytes
........
  r60041 | christian.heimes | 2008-01-18 09:47:59 +0100 (Fri, 18 Jan 2008) | 4 lines
  Coverity issue CID #169
  local_ptr_assign_local: Assigning address of stack variable "namebuf" to pointer "filename"
  out_of_scope: Variable "namebuf" goes out of scope
  use_invalid: Used "filename" pointing to out-of-scope variable "namebuf"
........
  r60042 | christian.heimes | 2008-01-18 09:53:45 +0100 (Fri, 18 Jan 2008) | 2 lines
  Coverity CID #168
  leaked_storage: Returned without freeing storage "fp"
........
											
										 
											2008-01-18 09:56:22 +00:00
										 |  |  |    If there has been no previous ``EHLO`` or ``HELO`` command this session,
 | 
					
						
							|  |  |  |    this method tries ESMTP ``EHLO`` first.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    :exc:`SMTPHeloError`
 | 
					
						
							|  |  |  |       The server didn't reply properly to the ``HELO`` greeting.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-16 13:58:14 -04:00
										 |  |  |    :exc:`SMTPNotSupportedError`
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 59985-60000,60002,60005-60007,60009-60042 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r59987 | raymond.hettinger | 2008-01-15 21:52:42 +0100 (Tue, 15 Jan 2008) | 1 line
  Refactor if/elif chain for clarity and speed.  Remove dependency on subclasses having to implement _empty and _full.
........
  r59988 | raymond.hettinger | 2008-01-15 22:22:47 +0100 (Tue, 15 Jan 2008) | 1 line
  Fix-up half-written paragraph in the docs
........
  r59989 | amaury.forgeotdarc | 2008-01-15 22:25:11 +0100 (Tue, 15 Jan 2008) | 3 lines
  test_doctest fails since r59984.
  Not sure if these are the correct values, but save_stdout has to be set before its usage...
........
  r59992 | andrew.kuchling | 2008-01-16 01:32:03 +0100 (Wed, 16 Jan 2008) | 1 line
  Docstring typos
........
  r59993 | andrew.kuchling | 2008-01-16 04:17:25 +0100 (Wed, 16 Jan 2008) | 1 line
  Add PEP 3141 section
........
  r59998 | andrew.kuchling | 2008-01-16 14:01:51 +0100 (Wed, 16 Jan 2008) | 1 line
  Markup fix
........
  r59999 | georg.brandl | 2008-01-16 17:56:29 +0100 (Wed, 16 Jan 2008) | 2 lines
  Fix MSDN library URL. (#1854)
........
  r60006 | georg.brandl | 2008-01-16 21:27:56 +0100 (Wed, 16 Jan 2008) | 3 lines
  Add Python-specific content to Doc dir. Update configuration file
  to work with the newest Sphinx.
........
  r60007 | georg.brandl | 2008-01-16 21:29:00 +0100 (Wed, 16 Jan 2008) | 2 lines
  Doc build should work with 2.4 now.
........
  r60009 | raymond.hettinger | 2008-01-17 00:38:16 +0100 (Thu, 17 Jan 2008) | 1 line
  Minor wordsmithing.
........
  r60010 | raymond.hettinger | 2008-01-17 00:40:45 +0100 (Thu, 17 Jan 2008) | 1 line
  Add queues will alternative fetch orders (priority based and stack based).
........
  r60011 | raymond.hettinger | 2008-01-17 00:49:35 +0100 (Thu, 17 Jan 2008) | 1 line
  Add news entry.
........
  r60013 | raymond.hettinger | 2008-01-17 04:02:14 +0100 (Thu, 17 Jan 2008) | 1 line
  Make starmap() match its pure python definition and accept any itertable input (not just tuples).
........
  r60015 | gregory.p.smith | 2008-01-17 08:43:20 +0100 (Thu, 17 Jan 2008) | 3 lines
  Comply with RFC 3207.
  Fixes issue 829951 - http://bugs.python.org/issue829951
........
  r60018 | gregory.p.smith | 2008-01-17 09:03:17 +0100 (Thu, 17 Jan 2008) | 2 lines
  entry for r60015
........
  r60019 | raymond.hettinger | 2008-01-17 09:07:05 +0100 (Thu, 17 Jan 2008) | 1 line
  Note versionadded.
........
  r60020 | gregory.p.smith | 2008-01-17 09:35:49 +0100 (Thu, 17 Jan 2008) | 8 lines
  Fixes (accepts patch) issue1339 - http://bugs.python.org/issue1339
  - Factor out the duplication of EHLO/HELO in login() and sendmail() to
    a new function, ehlo_or_helo_if_needed().
  - Use ehlo_or_helo_if_needed() in starttls()
  - Check for the starttls exception in starttls() in the same way as
    login() checks for the auth extension.
  Contributed by Bill Fenner.
........
  r60021 | andrew.kuchling | 2008-01-17 13:00:15 +0100 (Thu, 17 Jan 2008) | 1 line
  Revise 3141 section a bit; add some Windows items
........
  r60022 | brett.cannon | 2008-01-17 19:45:10 +0100 (Thu, 17 Jan 2008) | 2 lines
  Fix a function pointer declaration to silence the compiler.
........
  r60024 | raymond.hettinger | 2008-01-17 20:31:38 +0100 (Thu, 17 Jan 2008) | 1 line
  Issue #1861:  Add read-only attribute listing upcoming events in the order they will be run.
........
  r60025 | andrew.kuchling | 2008-01-17 20:49:24 +0100 (Thu, 17 Jan 2008) | 1 line
  Correction from Jordan Lewis: halfdelay() uses tenths of a second, not milliseconds
........
  r60026 | raymond.hettinger | 2008-01-17 23:27:49 +0100 (Thu, 17 Jan 2008) | 1 line
  Add advice on choosing between scheduler and threading.Timer().
........
  r60028 | christian.heimes | 2008-01-18 00:01:44 +0100 (Fri, 18 Jan 2008) | 2 lines
  Updated new property syntax. An elaborate example for subclassing and the getter was missing.
  Added comment about VS 2008 and PGO builds.
........
  r60029 | raymond.hettinger | 2008-01-18 00:32:01 +0100 (Fri, 18 Jan 2008) | 1 line
  Fix-up Timer() example.
........
  r60030 | raymond.hettinger | 2008-01-18 00:56:56 +0100 (Fri, 18 Jan 2008) | 1 line
  Fix markup
........
  r60031 | raymond.hettinger | 2008-01-18 01:10:42 +0100 (Fri, 18 Jan 2008) | 1 line
  clearcache() needs to remove the dict as well as clear it.
........
  r60033 | andrew.kuchling | 2008-01-18 03:26:16 +0100 (Fri, 18 Jan 2008) | 1 line
  Bump verson
........
  r60034 | andrew.kuchling | 2008-01-18 03:42:52 +0100 (Fri, 18 Jan 2008) | 1 line
  Typo fix
........
  r60035 | christian.heimes | 2008-01-18 08:30:20 +0100 (Fri, 18 Jan 2008) | 3 lines
  Coverity issue CID #197
  var_decl: Declared variable "stm" without initializer
  ninit_use_in_call: Using uninitialized value "stm" (field "stm".tm_zone uninitialized) in call to function "mktime"
........
  r60036 | christian.heimes | 2008-01-18 08:45:30 +0100 (Fri, 18 Jan 2008) | 11 lines
  Coverity issue CID #167
  Event alloc_fn: Called allocation function "metacompile" [model]
  Event var_assign: Assigned variable "gr" to storage returned from "metacompile"
  		gr = metacompile(n);
  Event pass_arg: Variable "gr" not freed or pointed-to in function "maketables" [model]
  		g = maketables(gr);
    		translatelabels(g);
    		addfirstsets(g);
  Event leaked_storage: Returned without freeing storage "gr"
  		return g;
........
  r60038 | christian.heimes | 2008-01-18 09:04:57 +0100 (Fri, 18 Jan 2008) | 3 lines
  Coverity issue CID #182
  size_error: Allocating 1 bytes to pointer "children", which needs at least 4 bytes
........
  r60041 | christian.heimes | 2008-01-18 09:47:59 +0100 (Fri, 18 Jan 2008) | 4 lines
  Coverity issue CID #169
  local_ptr_assign_local: Assigning address of stack variable "namebuf" to pointer "filename"
  out_of_scope: Variable "namebuf" goes out of scope
  use_invalid: Used "filename" pointing to out-of-scope variable "namebuf"
........
  r60042 | christian.heimes | 2008-01-18 09:53:45 +0100 (Fri, 18 Jan 2008) | 2 lines
  Coverity CID #168
  leaked_storage: Returned without freeing storage "fp"
........
											
										 
											2008-01-18 09:56:22 +00:00
										 |  |  |      The server does not support the STARTTLS extension.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    :exc:`RuntimeError`
 | 
					
						
							| 
									
										
										
										
											2009-12-19 23:26:38 +00:00
										 |  |  |      SSL/TLS support is not available to your Python interpreter.
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 59985-60000,60002,60005-60007,60009-60042 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r59987 | raymond.hettinger | 2008-01-15 21:52:42 +0100 (Tue, 15 Jan 2008) | 1 line
  Refactor if/elif chain for clarity and speed.  Remove dependency on subclasses having to implement _empty and _full.
........
  r59988 | raymond.hettinger | 2008-01-15 22:22:47 +0100 (Tue, 15 Jan 2008) | 1 line
  Fix-up half-written paragraph in the docs
........
  r59989 | amaury.forgeotdarc | 2008-01-15 22:25:11 +0100 (Tue, 15 Jan 2008) | 3 lines
  test_doctest fails since r59984.
  Not sure if these are the correct values, but save_stdout has to be set before its usage...
........
  r59992 | andrew.kuchling | 2008-01-16 01:32:03 +0100 (Wed, 16 Jan 2008) | 1 line
  Docstring typos
........
  r59993 | andrew.kuchling | 2008-01-16 04:17:25 +0100 (Wed, 16 Jan 2008) | 1 line
  Add PEP 3141 section
........
  r59998 | andrew.kuchling | 2008-01-16 14:01:51 +0100 (Wed, 16 Jan 2008) | 1 line
  Markup fix
........
  r59999 | georg.brandl | 2008-01-16 17:56:29 +0100 (Wed, 16 Jan 2008) | 2 lines
  Fix MSDN library URL. (#1854)
........
  r60006 | georg.brandl | 2008-01-16 21:27:56 +0100 (Wed, 16 Jan 2008) | 3 lines
  Add Python-specific content to Doc dir. Update configuration file
  to work with the newest Sphinx.
........
  r60007 | georg.brandl | 2008-01-16 21:29:00 +0100 (Wed, 16 Jan 2008) | 2 lines
  Doc build should work with 2.4 now.
........
  r60009 | raymond.hettinger | 2008-01-17 00:38:16 +0100 (Thu, 17 Jan 2008) | 1 line
  Minor wordsmithing.
........
  r60010 | raymond.hettinger | 2008-01-17 00:40:45 +0100 (Thu, 17 Jan 2008) | 1 line
  Add queues will alternative fetch orders (priority based and stack based).
........
  r60011 | raymond.hettinger | 2008-01-17 00:49:35 +0100 (Thu, 17 Jan 2008) | 1 line
  Add news entry.
........
  r60013 | raymond.hettinger | 2008-01-17 04:02:14 +0100 (Thu, 17 Jan 2008) | 1 line
  Make starmap() match its pure python definition and accept any itertable input (not just tuples).
........
  r60015 | gregory.p.smith | 2008-01-17 08:43:20 +0100 (Thu, 17 Jan 2008) | 3 lines
  Comply with RFC 3207.
  Fixes issue 829951 - http://bugs.python.org/issue829951
........
  r60018 | gregory.p.smith | 2008-01-17 09:03:17 +0100 (Thu, 17 Jan 2008) | 2 lines
  entry for r60015
........
  r60019 | raymond.hettinger | 2008-01-17 09:07:05 +0100 (Thu, 17 Jan 2008) | 1 line
  Note versionadded.
........
  r60020 | gregory.p.smith | 2008-01-17 09:35:49 +0100 (Thu, 17 Jan 2008) | 8 lines
  Fixes (accepts patch) issue1339 - http://bugs.python.org/issue1339
  - Factor out the duplication of EHLO/HELO in login() and sendmail() to
    a new function, ehlo_or_helo_if_needed().
  - Use ehlo_or_helo_if_needed() in starttls()
  - Check for the starttls exception in starttls() in the same way as
    login() checks for the auth extension.
  Contributed by Bill Fenner.
........
  r60021 | andrew.kuchling | 2008-01-17 13:00:15 +0100 (Thu, 17 Jan 2008) | 1 line
  Revise 3141 section a bit; add some Windows items
........
  r60022 | brett.cannon | 2008-01-17 19:45:10 +0100 (Thu, 17 Jan 2008) | 2 lines
  Fix a function pointer declaration to silence the compiler.
........
  r60024 | raymond.hettinger | 2008-01-17 20:31:38 +0100 (Thu, 17 Jan 2008) | 1 line
  Issue #1861:  Add read-only attribute listing upcoming events in the order they will be run.
........
  r60025 | andrew.kuchling | 2008-01-17 20:49:24 +0100 (Thu, 17 Jan 2008) | 1 line
  Correction from Jordan Lewis: halfdelay() uses tenths of a second, not milliseconds
........
  r60026 | raymond.hettinger | 2008-01-17 23:27:49 +0100 (Thu, 17 Jan 2008) | 1 line
  Add advice on choosing between scheduler and threading.Timer().
........
  r60028 | christian.heimes | 2008-01-18 00:01:44 +0100 (Fri, 18 Jan 2008) | 2 lines
  Updated new property syntax. An elaborate example for subclassing and the getter was missing.
  Added comment about VS 2008 and PGO builds.
........
  r60029 | raymond.hettinger | 2008-01-18 00:32:01 +0100 (Fri, 18 Jan 2008) | 1 line
  Fix-up Timer() example.
........
  r60030 | raymond.hettinger | 2008-01-18 00:56:56 +0100 (Fri, 18 Jan 2008) | 1 line
  Fix markup
........
  r60031 | raymond.hettinger | 2008-01-18 01:10:42 +0100 (Fri, 18 Jan 2008) | 1 line
  clearcache() needs to remove the dict as well as clear it.
........
  r60033 | andrew.kuchling | 2008-01-18 03:26:16 +0100 (Fri, 18 Jan 2008) | 1 line
  Bump verson
........
  r60034 | andrew.kuchling | 2008-01-18 03:42:52 +0100 (Fri, 18 Jan 2008) | 1 line
  Typo fix
........
  r60035 | christian.heimes | 2008-01-18 08:30:20 +0100 (Fri, 18 Jan 2008) | 3 lines
  Coverity issue CID #197
  var_decl: Declared variable "stm" without initializer
  ninit_use_in_call: Using uninitialized value "stm" (field "stm".tm_zone uninitialized) in call to function "mktime"
........
  r60036 | christian.heimes | 2008-01-18 08:45:30 +0100 (Fri, 18 Jan 2008) | 11 lines
  Coverity issue CID #167
  Event alloc_fn: Called allocation function "metacompile" [model]
  Event var_assign: Assigned variable "gr" to storage returned from "metacompile"
  		gr = metacompile(n);
  Event pass_arg: Variable "gr" not freed or pointed-to in function "maketables" [model]
  		g = maketables(gr);
    		translatelabels(g);
    		addfirstsets(g);
  Event leaked_storage: Returned without freeing storage "gr"
  		return g;
........
  r60038 | christian.heimes | 2008-01-18 09:04:57 +0100 (Fri, 18 Jan 2008) | 3 lines
  Coverity issue CID #182
  size_error: Allocating 1 bytes to pointer "children", which needs at least 4 bytes
........
  r60041 | christian.heimes | 2008-01-18 09:47:59 +0100 (Fri, 18 Jan 2008) | 4 lines
  Coverity issue CID #169
  local_ptr_assign_local: Assigning address of stack variable "namebuf" to pointer "filename"
  out_of_scope: Variable "namebuf" goes out of scope
  use_invalid: Used "filename" pointing to out-of-scope variable "namebuf"
........
  r60042 | christian.heimes | 2008-01-18 09:53:45 +0100 (Fri, 18 Jan 2008) | 2 lines
  Coverity CID #168
  leaked_storage: Returned without freeing storage "fp"
........
											
										 
											2008-01-18 09:56:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-18 18:03:09 +02:00
										 |  |  |    .. versionchanged:: 3.3
 | 
					
						
							|  |  |  |       *context* was added.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-02 20:44:17 +01:00
										 |  |  |    .. versionchanged:: 3.4
 | 
					
						
							|  |  |  |       The method now supports hostname check with
 | 
					
						
							|  |  |  |       :attr:`SSLContext.check_hostname` and *Server Name Indicator* (see
 | 
					
						
							|  |  |  |       :data:`~ssl.HAS_SNI`).
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-16 13:58:14 -04:00
										 |  |  |    .. versionchanged:: 3.5
 | 
					
						
							|  |  |  |       The error raised for lack of STARTTLS support is now the
 | 
					
						
							|  |  |  |       :exc:`SMTPNotSupportedError` subclass instead of the base
 | 
					
						
							|  |  |  |       :exc:`SMTPException`.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-02 20:34:52 +00:00
										 |  |  | .. method:: SMTP.sendmail(from_addr, to_addrs, msg, mail_options=[], rcpt_options=[])
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    Send mail.  The required arguments are an :rfc:`822` from-address string, a list
 | 
					
						
							|  |  |  |    of :rfc:`822` to-address strings (a bare string will be treated as a list with 1
 | 
					
						
							|  |  |  |    address), and a message string.  The caller may pass a list of ESMTP options
 | 
					
						
							|  |  |  |    (such as ``8bitmime``) to be used in ``MAIL FROM`` commands as *mail_options*.
 | 
					
						
							|  |  |  |    ESMTP options (such as ``DSN`` commands) that should be used with all ``RCPT``
 | 
					
						
							|  |  |  |    commands can be passed as *rcpt_options*.  (If you need to use different ESMTP
 | 
					
						
							|  |  |  |    options to different recipients you have to use the low-level methods such as
 | 
					
						
							|  |  |  |    :meth:`mail`, :meth:`rcpt` and :meth:`data` to send the message.)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    .. note::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       The *from_addr* and *to_addrs* parameters are used to construct the message
 | 
					
						
							| 
									
										
										
										
											2010-11-08 17:15:13 +00:00
										 |  |  |       envelope used by the transport agents.  ``sendmail`` does not modify the
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  |       message headers in any way.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-30 23:08:09 -06:00
										 |  |  |    *msg* may be a string containing characters in the ASCII range, or a byte
 | 
					
						
							| 
									
										
										
										
											2010-11-08 17:15:13 +00:00
										 |  |  |    string.  A string is encoded to bytes using the ascii codec, and lone ``\r``
 | 
					
						
							| 
									
										
										
										
											2011-12-30 23:08:09 -06:00
										 |  |  |    and ``\n`` characters are converted to ``\r\n`` characters.  A byte string is
 | 
					
						
							|  |  |  |    not modified.
 | 
					
						
							| 
									
										
										
										
											2010-11-08 17:15:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  |    If there has been no previous ``EHLO`` or ``HELO`` command this session, this
 | 
					
						
							|  |  |  |    method tries ESMTP ``EHLO`` first. If the server does ESMTP, message size and
 | 
					
						
							|  |  |  |    each of the specified options will be passed to it (if the option is in the
 | 
					
						
							|  |  |  |    feature set the server advertises).  If ``EHLO`` fails, ``HELO`` will be tried
 | 
					
						
							|  |  |  |    and ESMTP options suppressed.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This method will return normally if the mail is accepted for at least one
 | 
					
						
							| 
									
										
										
										
											2010-08-03 12:06:29 +00:00
										 |  |  |    recipient. Otherwise it will raise an exception.  That is, if this method does
 | 
					
						
							|  |  |  |    not raise an exception, then someone should get your mail. If this method does
 | 
					
						
							|  |  |  |    not raise an exception, it returns a dictionary, with one entry for each
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  |    recipient that was refused.  Each entry contains a tuple of the SMTP error code
 | 
					
						
							|  |  |  |    and the accompanying error message sent by the server.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-16 13:58:14 -04:00
										 |  |  |    If ``SMTPUTF8`` is included in *mail_options*, and the server supports it,
 | 
					
						
							| 
									
										
										
										
											2016-08-30 13:25:06 -07:00
										 |  |  |    *from_addr* and *to_addrs* may contain non-ASCII characters.
 | 
					
						
							| 
									
										
										
										
											2015-05-16 13:58:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  |    This method may raise the following exceptions:
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    :exc:`SMTPRecipientsRefused`
 | 
					
						
							|  |  |  |       All recipients were refused.  Nobody got the mail.  The :attr:`recipients`
 | 
					
						
							|  |  |  |       attribute of the exception object is a dictionary with information about the
 | 
					
						
							|  |  |  |       refused recipients (like the one returned when at least one recipient was
 | 
					
						
							|  |  |  |       accepted).
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    :exc:`SMTPHeloError`
 | 
					
						
							|  |  |  |       The server didn't reply properly to the ``HELO`` greeting.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    :exc:`SMTPSenderRefused`
 | 
					
						
							|  |  |  |       The server didn't accept the *from_addr*.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    :exc:`SMTPDataError`
 | 
					
						
							|  |  |  |       The server replied with an unexpected error code (other than a refusal of a
 | 
					
						
							|  |  |  |       recipient).
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-16 13:58:14 -04:00
										 |  |  |    :exc:`SMTPNotSupportedError`
 | 
					
						
							|  |  |  |       ``SMTPUTF8`` was given in the *mail_options* but is not supported by the
 | 
					
						
							|  |  |  |       server.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  |    Unless otherwise noted, the connection will be open even after an exception is
 | 
					
						
							|  |  |  |    raised.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-24 22:48:30 +02:00
										 |  |  |    .. versionchanged:: 3.2
 | 
					
						
							|  |  |  |       *msg* may be a byte string.
 | 
					
						
							| 
									
										
										
										
											2010-11-08 17:15:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-16 13:58:14 -04:00
										 |  |  |    .. versionchanged:: 3.5
 | 
					
						
							|  |  |  |       ``SMTPUTF8`` support added, and :exc:`SMTPNotSupportedError` may be
 | 
					
						
							|  |  |  |       raised if ``SMTPUTF8`` is specified but the server does not support it.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-08 17:15:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-02 21:03:19 -04:00
										 |  |  | .. method:: SMTP.send_message(msg, from_addr=None, to_addrs=None, \
 | 
					
						
							|  |  |  |                               mail_options=[], rcpt_options=[])
 | 
					
						
							| 
									
										
										
										
											2010-11-08 17:15:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    This is a convenience method for calling :meth:`sendmail` with the message
 | 
					
						
							|  |  |  |    represented by an :class:`email.message.Message` object.  The arguments have
 | 
					
						
							|  |  |  |    the same meaning as for :meth:`sendmail`, except that *msg* is a ``Message``
 | 
					
						
							|  |  |  |    object.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-02 21:03:19 -04:00
										 |  |  |    If *from_addr* is ``None`` or *to_addrs* is ``None``, ``send_message`` fills
 | 
					
						
							|  |  |  |    those arguments with addresses extracted from the headers of *msg* as
 | 
					
						
							| 
									
										
										
										
											2015-05-17 19:27:22 -04:00
										 |  |  |    specified in :rfc:`5322`\: *from_addr* is set to the :mailheader:`Sender`
 | 
					
						
							| 
									
										
										
										
											2011-07-02 21:03:19 -04:00
										 |  |  |    field if it is present, and otherwise to the :mailheader:`From` field.
 | 
					
						
							| 
									
										
										
										
											2016-08-30 13:25:06 -07:00
										 |  |  |    *to_addrs* combines the values (if any) of the :mailheader:`To`,
 | 
					
						
							| 
									
										
										
										
											2011-07-02 21:03:19 -04:00
										 |  |  |    :mailheader:`Cc`, and :mailheader:`Bcc` fields from *msg*.  If exactly one
 | 
					
						
							|  |  |  |    set of :mailheader:`Resent-*` headers appear in the message, the regular
 | 
					
						
							|  |  |  |    headers are ignored and the :mailheader:`Resent-*` headers are used instead.
 | 
					
						
							|  |  |  |    If the message contains more than one set of :mailheader:`Resent-*` headers,
 | 
					
						
							|  |  |  |    a :exc:`ValueError` is raised, since there is no way to unambiguously detect
 | 
					
						
							|  |  |  |    the most recent set of :mailheader:`Resent-` headers.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    ``send_message`` serializes *msg* using
 | 
					
						
							| 
									
										
										
										
											2010-11-08 17:15:13 +00:00
										 |  |  |    :class:`~email.generator.BytesGenerator` with ``\r\n`` as the *linesep*, and
 | 
					
						
							| 
									
										
										
										
											2011-07-02 21:03:19 -04:00
										 |  |  |    calls :meth:`sendmail` to transmit the resulting message.  Regardless of the
 | 
					
						
							|  |  |  |    values of *from_addr* and *to_addrs*, ``send_message`` does not transmit any
 | 
					
						
							|  |  |  |    :mailheader:`Bcc` or :mailheader:`Resent-Bcc` headers that may appear
 | 
					
						
							| 
									
										
										
										
											2015-05-17 19:27:22 -04:00
										 |  |  |    in *msg*.  If any of the addresses in *from_addr* and *to_addrs* contain
 | 
					
						
							|  |  |  |    non-ASCII characters and the server does not advertise ``SMTPUTF8`` support,
 | 
					
						
							|  |  |  |    an :exc:`SMTPNotSupported` error is raised.  Otherwise the ``Message`` is
 | 
					
						
							|  |  |  |    serialized with a clone of its :mod:`~email.policy` with the
 | 
					
						
							|  |  |  |    :attr:`~email.policy.EmailPolicy.utf8` attribute set to ``True``, and
 | 
					
						
							|  |  |  |    ``SMTPUTF8`` and ``BODY=8BITMIME`` are added to *mail_options*.
 | 
					
						
							| 
									
										
										
										
											2010-11-08 17:15:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    .. versionadded:: 3.2
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 19:27:22 -04:00
										 |  |  |    .. versionadded:: 3.5
 | 
					
						
							|  |  |  |       Support for internationalized addresses (``SMTPUTF8``).
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | .. method:: SMTP.quit()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 61964-61979 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r61964 | benjamin.peterson | 2008-03-27 01:25:33 +0100 (Thu, 27 Mar 2008) | 2 lines
  add commas for introductory clauses
........
  r61965 | christian.heimes | 2008-03-27 02:36:21 +0100 (Thu, 27 Mar 2008) | 1 line
  Hopefully added _fileio module to the Windows build system
........
  r61966 | christian.heimes | 2008-03-27 02:38:47 +0100 (Thu, 27 Mar 2008) | 1 line
  Revert commit accident
........
  r61967 | neal.norwitz | 2008-03-27 04:49:54 +0100 (Thu, 27 Mar 2008) | 3 lines
  Fix bytes so it works on 64-bit platforms.
  (Also remove some #if 0 code that is already handled in _getbytevalue.)
........
  r61968 | neal.norwitz | 2008-03-27 05:40:07 +0100 (Thu, 27 Mar 2008) | 1 line
  Fix memory leaks
........
  r61969 | neal.norwitz | 2008-03-27 05:40:50 +0100 (Thu, 27 Mar 2008) | 3 lines
  Fix warnings about using char as an array subscript.  This is not portable
  since char is signed on some platforms and unsigned on others.
........
  r61970 | neal.norwitz | 2008-03-27 06:02:57 +0100 (Thu, 27 Mar 2008) | 1 line
  Fix test_compiler after adding unicode_literals
........
  r61971 | neal.norwitz | 2008-03-27 06:03:11 +0100 (Thu, 27 Mar 2008) | 1 line
  Fix compiler warnings
........
  r61972 | neal.norwitz | 2008-03-27 07:52:01 +0100 (Thu, 27 Mar 2008) | 1 line
  Pluralss only need one s, not 2 (intss -> ints)
........
  r61973 | christian.heimes | 2008-03-27 10:02:33 +0100 (Thu, 27 Mar 2008) | 1 line
  Quick 'n dirty hack: Increase the magic by 2 to force a rebuild of pyc/pyo files on the build bots
........
  r61974 | eric.smith | 2008-03-27 10:42:35 +0100 (Thu, 27 Mar 2008) | 3 lines
  Added test cases for single quoted strings, both forms of triple quotes,
   and some string concatenations.
  Removed unneeded __future__ print_function import.
........
  r61975 | christian.heimes | 2008-03-27 11:35:52 +0100 (Thu, 27 Mar 2008) | 1 line
  Build bots are working again - removing the hack
........
  r61976 | christian.heimes | 2008-03-27 12:46:37 +0100 (Thu, 27 Mar 2008) | 2 lines
  Fixed tokenize tests
  The tokenize module doesn't understand __future__.unicode_literals yet
........
  r61977 | georg.brandl | 2008-03-27 14:27:31 +0100 (Thu, 27 Mar 2008) | 2 lines
  #2248: return result of QUIT from quit().
........
  r61978 | georg.brandl | 2008-03-27 14:34:59 +0100 (Thu, 27 Mar 2008) | 2 lines
  The bug for which there was a test in outstanding_bugs.py was agreed not to be a bug.
........
  r61979 | amaury.forgeotdarc | 2008-03-28 00:23:54 +0100 (Fri, 28 Mar 2008) | 5 lines
  Issue2495: tokenize.untokenize did not insert space between two consecutive string literals:
  "" "" => """", which is invalid code.
  Will backport
........
											
										 
											2008-03-28 00:55:15 +00:00
										 |  |  |    Terminate the SMTP session and close the connection.  Return the result of
 | 
					
						
							|  |  |  |    the SMTP ``QUIT`` command.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | Low-level methods corresponding to the standard SMTP/ESMTP commands ``HELP``,
 | 
					
						
							|  |  |  | ``RSET``, ``NOOP``, ``MAIL``, ``RCPT``, and ``DATA`` are also supported.
 | 
					
						
							|  |  |  | Normally these do not need to be called directly, so they are not documented
 | 
					
						
							|  |  |  | here.  For details, consult the module code.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .. _smtp-example:
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SMTP Example
 | 
					
						
							|  |  |  | ------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This example prompts the user for addresses needed in the message envelope ('To'
 | 
					
						
							|  |  |  | and 'From' addresses), and the message to be delivered.  Note that the headers
 | 
					
						
							|  |  |  | to be included with the message must be included in the message as entered; this
 | 
					
						
							|  |  |  | example doesn't do any processing of the :rfc:`822` headers.  In particular, the
 | 
					
						
							|  |  |  | 'To' and 'From' addresses must be included in the message headers explicitly. ::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    import smtplib
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    def prompt(prompt):
 | 
					
						
							| 
									
										
										
										
											2007-12-02 22:48:17 +00:00
										 |  |  |        return input(prompt).strip()
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    fromaddr = prompt("From: ")
 | 
					
						
							|  |  |  |    toaddrs  = prompt("To: ").split()
 | 
					
						
							| 
									
										
										
										
											2007-09-04 07:15:32 +00:00
										 |  |  |    print("Enter message, end with ^D (Unix) or ^Z (Windows):")
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    # Add the From: and To: headers at the start!
 | 
					
						
							|  |  |  |    msg = ("From: %s\r\nTo: %s\r\n\r\n"
 | 
					
						
							|  |  |  |           % (fromaddr, ", ".join(toaddrs)))
 | 
					
						
							| 
									
										
										
										
											2007-09-10 00:49:57 +00:00
										 |  |  |    while True:
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  |        try:
 | 
					
						
							| 
									
										
										
										
											2007-12-02 22:48:17 +00:00
										 |  |  |            line = input()
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  |        except EOFError:
 | 
					
						
							|  |  |  |            break
 | 
					
						
							|  |  |  |        if not line:
 | 
					
						
							|  |  |  |            break
 | 
					
						
							|  |  |  |        msg = msg + line
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-04 07:15:32 +00:00
										 |  |  |    print("Message length is", len(msg))
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    server = smtplib.SMTP('localhost')
 | 
					
						
							|  |  |  |    server.set_debuglevel(1)
 | 
					
						
							|  |  |  |    server.sendmail(fromaddr, toaddrs, msg)
 | 
					
						
							|  |  |  |    server.quit()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merged revisions 72506,72525-72526,72551,72558,72616,72654-72655,72689,72745,72750,72802,72812,72822,72824,72826-72827,72833,72876,72890,72923,72946,73026,73042,73045,73047,73065,73068-73069 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r72506 | vinay.sajip | 2009-05-09 07:07:17 -0500 (Sat, 09 May 2009) | 1 line
  Issue #5971: StreamHandler.handleError now swallows IOErrors which occur when trying to print a traceback.
........
  r72525 | benjamin.peterson | 2009-05-09 20:38:02 -0500 (Sat, 09 May 2009) | 1 line
  close file explicitly
........
  r72526 | benjamin.peterson | 2009-05-09 21:29:00 -0500 (Sat, 09 May 2009) | 1 line
  make sure files are closed using the with statement
........
  r72551 | benjamin.peterson | 2009-05-10 09:16:47 -0500 (Sun, 10 May 2009) | 1 line
  use isinstance
........
  r72558 | benjamin.peterson | 2009-05-10 18:52:09 -0500 (Sun, 10 May 2009) | 1 line
  sys.setdefaultencoding() strikes me as a bad example
........
  r72616 | benjamin.peterson | 2009-05-13 19:33:10 -0500 (Wed, 13 May 2009) | 1 line
  importlib.import_module is better these days
........
  r72654 | benjamin.peterson | 2009-05-14 17:37:49 -0500 (Thu, 14 May 2009) | 1 line
  prevent refleaks from threads
........
  r72655 | benjamin.peterson | 2009-05-14 17:40:34 -0500 (Thu, 14 May 2009) | 1 line
  a useful decorator for cleaning up threads
........
  r72689 | benjamin.peterson | 2009-05-16 13:44:34 -0500 (Sat, 16 May 2009) | 1 line
  use skipTest()
........
  r72745 | benjamin.peterson | 2009-05-17 09:16:29 -0500 (Sun, 17 May 2009) | 1 line
  ignore .rst files in sphinx its self
........
  r72750 | benjamin.peterson | 2009-05-17 11:59:27 -0500 (Sun, 17 May 2009) | 1 line
  chop off slash
........
  r72802 | georg.brandl | 2009-05-20 13:35:27 -0500 (Wed, 20 May 2009) | 1 line
  #6051: refer to email examples for better way to construct email messages.
........
  r72812 | michael.foord | 2009-05-21 17:57:02 -0500 (Thu, 21 May 2009) | 1 line
  Rename TestCase._result to _resultForDoCleanups to avoid potential clashes in TestCase subclasses. Issue 6072.
........
  r72822 | georg.brandl | 2009-05-22 04:33:25 -0500 (Fri, 22 May 2009) | 1 line
  #6084: fix example.
........
  r72824 | georg.brandl | 2009-05-22 04:43:17 -0500 (Fri, 22 May 2009) | 1 line
  Fix references to file-related functions and methods (os.* vs file.*).
........
  r72826 | georg.brandl | 2009-05-22 04:49:42 -0500 (Fri, 22 May 2009) | 1 line
  Fix confusing wording.
........
  r72827 | georg.brandl | 2009-05-22 04:50:30 -0500 (Fri, 22 May 2009) | 1 line
  s/use/call/
........
  r72833 | georg.brandl | 2009-05-22 12:00:17 -0500 (Fri, 22 May 2009) | 1 line
  #6078: _warnings is a builtin module and has no standard init_warnings function.
........
  r72876 | benjamin.peterson | 2009-05-23 15:59:09 -0500 (Sat, 23 May 2009) | 1 line
  remove mention of old ctypes version
........
  r72890 | gregory.p.smith | 2009-05-24 13:00:13 -0500 (Sun, 24 May 2009) | 2 lines
  add a versionadded tag for set_tunnel
........
  r72923 | michael.foord | 2009-05-25 15:36:56 -0500 (Mon, 25 May 2009) | 1 line
  Make assertSequenceEqual error messages less cryptic, particularly for nested sequences.
........
  r72946 | ronald.oussoren | 2009-05-26 13:44:48 -0500 (Tue, 26 May 2009) | 2 lines
  Fixes issue 6110
........
  r73026 | r.david.murray | 2009-05-29 14:30:27 -0500 (Fri, 29 May 2009) | 3 lines
  Issue 6141: document that the first item of args is still the
  command name even when executable is specified.
........
  r73042 | benjamin.peterson | 2009-05-29 22:10:52 -0500 (Fri, 29 May 2009) | 1 line
  no fdatasync on macos
........
  r73045 | georg.brandl | 2009-05-30 02:26:04 -0500 (Sat, 30 May 2009) | 1 line
  #6146: fix markup bug.
........
  r73047 | georg.brandl | 2009-05-30 05:33:23 -0500 (Sat, 30 May 2009) | 1 line
  Fix some more small markup problems.
........
  r73065 | antoine.pitrou | 2009-05-30 16:39:25 -0500 (Sat, 30 May 2009) | 3 lines
  The test for #5330 wasn't correct.
........
  r73068 | antoine.pitrou | 2009-05-30 16:45:40 -0500 (Sat, 30 May 2009) | 3 lines
  Update ACKS
........
  r73069 | benjamin.peterson | 2009-05-30 19:42:42 -0500 (Sat, 30 May 2009) | 1 line
  fix signature
........
											
										 
											2009-06-01 22:42:33 +00:00
										 |  |  | .. note::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    In general, you will want to use the :mod:`email` package's features to
 | 
					
						
							| 
									
										
										
										
											2010-11-08 17:15:13 +00:00
										 |  |  |    construct an email message, which you can then send
 | 
					
						
							|  |  |  |    via :meth:`~smtplib.SMTP.send_message`; see :ref:`email-examples`.
 |