Author thunderk
Recipients thunderk
Date 2018-01-30.15:10:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1517325032.97.0.467229070634.issue32727@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,

I noticed that SMTP.send_message, when getting the sender and recipients from the Message object, strips the name from recipients (to keep only the address), but not from the sender.

        if from_addr is None:
            # Prefer the sender field per RFC 2822:3.6.2.
            from_addr = (msg[header_prefix + 'Sender']
                           if (header_prefix + 'Sender') in msg
                           else msg[header_prefix + 'From'])
        if to_addrs is None:
            addr_fields = [f for f in (msg[header_prefix + 'To'],
                                       msg[header_prefix + 'Bcc'],
                                       msg[header_prefix + 'Cc'])
                           if f is not None]
            to_addrs = [a[1] for a in email.utils.getaddresses(addr_fields)]

There is an ugly side-effect to that (starting with Python 3.5) : if the sender name contains a non-ascii character, send_message will then require the SMTPUTF8 option from the SMTP server, and raise a SMTPNotSupportedError if unavailable. This is not wanted because the sender name is not actually sent to the SMTP server in the "MAIL FROM:" command (it is only sent in the MIME payload), so the SMTPUTF8 option should not be required based on it (it should only depend on the addresses).
History
Date User Action Args
2018-01-30 15:10:33thunderksetrecipients: + thunderk
2018-01-30 15:10:32thunderksetmessageid: <1517325032.97.0.467229070634.issue32727@psf.upfronthosting.co.za>
2018-01-30 15:10:32thunderklinkissue32727 messages
2018-01-30 15:10:32thunderkcreate