Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(32823)

Delta Between Two Patch Sets: Doc/library/smtplib.rst

Issue 10321: Add support for Message objects and binary data to smtplib.sendmail
Left Patch Set: Created 8 years, 10 months ago
Right Patch Set: Created 8 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Doc/includes/email-simple.py ('k') | Doc/whatsnew/3.2.rst » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 :mod:`smtplib` --- SMTP protocol client 1 :mod:`smtplib` --- SMTP protocol client
2 ======================================= 2 =======================================
3 3
4 .. module:: smtplib 4 .. module:: smtplib
5 :synopsis: SMTP protocol client (requires sockets). 5 :synopsis: SMTP protocol client (requires sockets).
6 .. sectionauthor:: Eric S. Raymond <esr@snark.thyrsus.com> 6 .. sectionauthor:: Eric S. Raymond <esr@snark.thyrsus.com>
7 7
8 8
9 .. index:: 9 .. index::
10 pair: SMTP; protocol 10 pair: SMTP; protocol
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 :exc:`SMTPSenderRefused` 309 :exc:`SMTPSenderRefused`
310 The server didn't accept the *from_addr*. 310 The server didn't accept the *from_addr*.
311 311
312 :exc:`SMTPDataError` 312 :exc:`SMTPDataError`
313 The server replied with an unexpected error code (other than a refusal of a 313 The server replied with an unexpected error code (other than a refusal of a
314 recipient). 314 recipient).
315 315
316 Unless otherwise noted, the connection will be open even after an exception i s 316 Unless otherwise noted, the connection will be open even after an exception i s
317 raised. 317 raised.
318 318
319 .. versionchanged:: 3.2 *msg* may be a byte string.
320
319 321
320 .. method:: SMTP.send_message(msg, from_addr=None, to_addrs=None, mail_options=[ ], rcpt_options=[]) 322 .. method:: SMTP.send_message(msg, from_addr=None, to_addrs=None, mail_options=[ ], rcpt_options=[])
321 323
322 This is a convenience method for calling :meth:`sendmail` with the message 324 This is a convenience method for calling :meth:`sendmail` with the message
323 represented by an :class:`email.message.Message` object. The arguments have 325 represented by an :class:`email.message.Message` object. The arguments have
324 the same meaning as for :meth:`sendmail`, except that *msg* is a ``Message`` 326 the same meaning as for :meth:`sendmail`, except that *msg* is a ``Message``
325 object. 327 object.
326 328
327 If *from_addr* is ``None``, ``send_message`` sets its value to the value of 329 If *from_addr* is ``None``, ``send_message`` sets its value to the value of
328 the :mailheader:`From` header from *msg*. If *to_addrs* is ``None``, 330 the :mailheader:`From` header from *msg*. If *to_addrs* is ``None``,
329 ``send_message`` combines the values (if any) of the :mailheader:`To`, 331 ``send_message`` combines the values (if any) of the :mailheader:`To`,
330 :mailheader:`CC`, and :mailheader:`Bcc` fields from *msg*. Regardless of 332 :mailheader:`CC`, and :mailheader:`Bcc` fields from *msg*. Regardless of
331 the values of *from_addr* and *to_addrs*, ``send_message`` deletes any Bcc 333 the values of *from_addr* and *to_addrs*, ``send_message`` deletes any Bcc
332 field from *msg*. It then serializes *msg* using 334 field from *msg*. It then serializes *msg* using
333 :class:`~email.generator.BytesGenerator` with ``\r\n`` as the *linesep*, and 335 :class:`~email.generator.BytesGenerator` with ``\r\n`` as the *linesep*, and
334 calls :meth:`sendmail` to transmit the resulting message. 336 calls :meth:`sendmail` to transmit the resulting message.
337
338 .. versionadded:: 3.2
335 339
336 340
337 .. method:: SMTP.quit() 341 .. method:: SMTP.quit()
338 342
339 Terminate the SMTP session and close the connection. Return the result of 343 Terminate the SMTP session and close the connection. Return the result of
340 the SMTP ``QUIT`` command. 344 the SMTP ``QUIT`` command.
341 345
342 346
343 Low-level methods corresponding to the standard SMTP/ESMTP commands ``HELP``, 347 Low-level methods corresponding to the standard SMTP/ESMTP commands ``HELP``,
344 ``RSET``, ``NOOP``, ``MAIL``, ``RCPT``, and ``DATA`` are also supported. 348 ``RSET``, ``NOOP``, ``MAIL``, ``RCPT``, and ``DATA`` are also supported.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 server = smtplib.SMTP('localhost') 387 server = smtplib.SMTP('localhost')
384 server.set_debuglevel(1) 388 server.set_debuglevel(1)
385 server.sendmail(fromaddr, toaddrs, msg) 389 server.sendmail(fromaddr, toaddrs, msg)
386 server.quit() 390 server.quit()
387 391
388 .. note:: 392 .. note::
389 393
390 In general, you will want to use the :mod:`email` package's features to 394 In general, you will want to use the :mod:`email` package's features to
391 construct an email message, which you can then send 395 construct an email message, which you can then send
392 via :meth:`~smtplib.SMTP.send_message`; see :ref:`email-examples`. 396 via :meth:`~smtplib.SMTP.send_message`; see :ref:`email-examples`.
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+