cpython: 30795a477f85 (original) (raw)

Mercurial > cpython

changeset 96126:30795a477f85

#24218: Add SMTPUTF8 support to send_message. Reviewed by Maciej Szulik. [#24218]

R David Murray rdmurray@bitdance.com
date Sun, 17 May 2015 19:27:22 -0400
parents 257ea04df092
children 4a254750ad20
files Doc/library/smtplib.rst Doc/whatsnew/3.5.rst Lib/smtplib.py Lib/test/test_smtplib.py
diffstat 4 files changed, 86 insertions(+), 8 deletions(-)[+] [-] Doc/library/smtplib.rst 12 Doc/whatsnew/3.5.rst 6 Lib/smtplib.py 29 Lib/test/test_smtplib.py 47

line wrap: on

line diff

--- a/Doc/library/smtplib.rst +++ b/Doc/library/smtplib.rst @@ -467,7 +467,7 @@ An :class:SMTP instance has the follow If from_addr is None or to_addrs is None, send_message fills those arguments with addresses extracted from the headers of msg as

+ .. method:: SMTP.quit()

--- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -557,8 +557,10 @@ smtplib :class:smtplib.SMTP. (Contributed by Gavin Chappell and Maciej Szulik in :issue:16914.) -* :mod:smtplib now support :rfc:6531 (SMTPUTF8). (Contributed by

--- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -872,7 +872,13 @@ class SMTP: to_addr, any Bcc field (or Resent-Bcc field, when the Message is a resent) of the Message object won't be transmitted. The Message object is then serialized using email.generator.BytesGenerator and

""" # 'Resent-Date' is a mandatory field if the Message is resent (RFC 2822 @@ -885,6 +891,7 @@ class SMTP: # option allowing the user to enable the heuristics. (It should be # possible to guess correctly almost all of the time.)

@@ -900,14 +907,30 @@ class SMTP: if to_addrs is None: addr_fields = [f for f in (msg[header_prefix + 'To'], msg[header_prefix + 'Bcc'],

--- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -1,5 +1,6 @@ import asyncore import email.mime.text +from email.message import EmailMessage import email.utils import socket import smtpd @@ -10,7 +11,7 @@ import sys import time import select import errno -import base64 +import textwrap import unittest from test import support, mock_socket @@ -1029,6 +1030,8 @@ class SimSMTPUTF8Server(SimSMTPServer): @unittest.skipUnless(threading, 'Threading required for this test.') class SMTPUTF8SimTests(unittest.TestCase):

+ def setUp(self): self.real_getfqdn = socket.getfqdn socket.getfqdn = mock_socket.getfqdn @@ -1096,6 +1099,48 @@ class SMTPUTF8SimTests(unittest.TestCase self.assertIn('SMTPUTF8', self.serv.last_mail_options) self.assertEqual(self.serv.last_rcpt_options, [])

+

+

+ @support.reap_threads def test_main(verbose=None):