Changeset 391 for python/trunk/Doc/library/smtplib.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/smtplib.rst
r2 r391 1 2 1 :mod:`smtplib` --- SMTP protocol client 3 2 ======================================= … … 11 10 pair: SMTP; protocol 12 11 single: Simple Mail Transfer Protocol 12 13 **Source code:** :source:`Lib/smtplib.py` 14 15 -------------- 13 16 14 17 The :mod:`smtplib` module defines an SMTP client session object that can be used … … 22 25 A :class:`SMTP` instance encapsulates an SMTP connection. It has methods 23 26 that support a full repertoire of SMTP and ESMTP operations. If the optional 24 host and port parameters are given, the SMTP :meth:`connect` method is called 25 with those parameters during initialization. An :exc:`SMTPConnectError` is 26 raised if the specified host doesn't respond correctly. The optional 27 host and port parameters are given, the SMTP :meth:`connect` method is 28 called with those parameters during initialization. If specified, 29 *local_hostname* is used as the FQDN of the local host in the HELO/EHLO 30 command. Otherwise, the local hostname is found using 31 :func:`socket.getfqdn`. If the :meth:`connect` call returns anything other 32 than a success code, an :exc:`SMTPConnectError` is raised. The optional 27 33 *timeout* parameter specifies a timeout in seconds for blocking operations 28 34 like the connection attempt (if not specified, the global default timeout … … 30 36 31 37 For normal use, you should only require the initialization/connect, 32 :meth:`sendmail`, and :meth:`quit` methods. An example is included below. 38 :meth:`sendmail`, and :meth:`~smtplib.quit` methods. 39 An example is included below. 33 40 34 41 .. versionchanged:: 2.6 … … 42 49 required from the beginning of the connection and using :meth:`starttls` is 43 50 not appropriate. If *host* is not specified, the local host is used. If 44 *port* is omitted, the standard SMTP-over-SSL port (465) is used. *keyfile*45 and *certfile* are also optional, and can contain a PEM formatted private key46 and certificate chain file for the SSL connection. The optional *timeout*47 parameter specifies a timeout in seconds for blocking operations like the48 connection attempt (if not specified, the global default timeout setting49 will be used).50 51 .. versionchanged:: 2.6 52 *timeout* was added.51 *port* is omitted, the standard SMTP-over-SSL port (465) is used. 52 *local_hostname* has the same meaning as it does for the :class:`SMTP` 53 class. *keyfile* and *certfile* are also optional, and can contain a PEM 54 formatted private key and certificate chain file for the SSL connection. The 55 optional *timeout* parameter specifies a timeout in seconds for blocking 56 operations like the connection attempt (if not specified, the global default 57 timeout setting will be used). 58 59 .. versionadded:: 2.6 53 60 54 61 … … 56 63 57 64 The LMTP protocol, which is very similar to ESMTP, is heavily based on the 58 standard SMTP client. It's common to use Unix sockets for LMTP, so our :meth:`connect` 59 method must support that as well as a regular host:port server. To specify a 60 Unix socket, you must use an absolute path for *host*, starting with a '/'. 61 62 Authentication is supported, using the regular SMTP mechanism. When using a Unix 63 socket, LMTP generally don't support or require any authentication, but your 64 mileage might vary. 65 standard SMTP client. It's common to use Unix sockets for LMTP, so our 66 :meth:`connect` method must support that as well as a regular host:port 67 server. *local_hostname* has the same meaning as it does for the 68 :class:`SMTP` class. To specify a Unix socket, you must use an absolute 69 path for *host*, starting with a '/'. 70 71 Authentication is supported, using the regular SMTP mechanism. When using a 72 Unix socket, LMTP generally don't support or require any authentication, but 73 your mileage might vary. 65 74 66 75 .. versionadded:: 2.6 … … 71 80 .. exception:: SMTPException 72 81 73 Base exception class for all exceptions raised by this module. 82 The base exception class for all the other exceptions provided by this 83 module. 74 84 75 85 … … 150 160 151 161 162 .. method:: SMTP.docmd(cmd, [, argstring]) 163 164 Send a command *cmd* to the server. The optional argument *argstring* is simply 165 concatenated to the command, separated by a space. 166 167 This returns a 2-tuple composed of a numeric response code and the actual 168 response line (multiline responses are joined into one long line.) 169 170 In normal operation it should not be necessary to call this method explicitly. 171 It is used to implement other methods and may be useful for testing private 172 extensions. 173 174 If the connection to the server is lost while waiting for the reply, 175 :exc:`SMTPServerDisconnected` will be raised. 176 177 152 178 .. method:: SMTP.connect([host[, port]]) 153 179 … … 156 182 followed by a number, that suffix will be stripped off and the number 157 183 interpreted as the port number to use. This method is automatically invoked by 158 the constructor if a host is specified during instantiation. 159 160 161 .. method:: SMTP.docmd(cmd, [, argstring]) 162 163 Send a command *cmd* to the server. The optional argument *argstring* is simply 164 concatenated to the command, separated by a space. 165 166 This returns a 2-tuple composed of a numeric response code and the actual 167 response line (multiline responses are joined into one long line.) 168 169 In normal operation it should not be necessary to call this method explicitly. 170 It is used to implement other methods and may be useful for testing private 171 extensions. 172 173 If the connection to the server is lost while waiting for the reply, 174 :exc:`SMTPServerDisconnected` will be raised. 184 the constructor if a host is specified during instantiation. Returns a 185 2-tuple of the response code and message sent by the server in its 186 connection response. 175 187 176 188 … … 299 311 300 312 This method will return normally if the mail is accepted for at least one 301 recipient. Otherwise it will throwan exception. That is, if this method does302 not throwan exception, then someone should get your mail. If this method does303 not throwan exception, it returns a dictionary, with one entry for each313 recipient. Otherwise it will raise an exception. That is, if this method does 314 not raise an exception, then someone should get your mail. If this method does 315 not raise an exception, it returns a dictionary, with one entry for each 304 316 recipient that was refused. Each entry contains a tuple of the SMTP error code 305 317 and the accompanying error message sent by the server.
Note:
See TracChangeset
for help on using the changeset viewer.