classification
Title: smtplib.SMTP.login() breaks with unicode input
Type: crash Stage:
Components: Unicode Versions: Python 2.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: exarkun, iElectric
Priority: normal Keywords:

Created on 2010-04-21 19:17 by iElectric, last changed 2010-04-21 19:56 by iElectric.

Messages (3)
msg103890 - (view) Author: Domen Kožar (iElectric) Date: 2010-04-21 19:17
Module smtplib, line 574, in login
  Module smtplib, line 538, in encode_cram_md5
  Module hmac, line 72, in __init__
TypeError: character mapping must return integer, None or unicode

Following traceback occurs when doing connection.login(u'foobar@domain.com', 'justdoit') to issue an ESMTP.

Python 2.6.4 (r264:75706, Mar 11 2010, 18:33:18)
msg103893 - (view) Author: Jean-Paul Calderone (exarkun) * (Python committer) Date: 2010-04-21 19:24
SMTP (RFC 2821) doesn't support non-ASCII envelope addresses.  A better behavior here would be for connection.login to raise a ValueError or a TypeError whenever a non-str is passed in.

RFC 5336, though, adds the UTF8SMTP extension, which adds support for UTF-8 encoded unicode mailboxes.  If the server advertises the UTF8SMTP capability, then smtplib could encode unicode using UTF-8 and pass it on.

This is really a feature request (RFC 5336 support), not a bug.
msg103901 - (view) Author: Domen Kožar (iElectric) Date: 2010-04-21 19:56
Plone currently just passes unicode data around, maybe additional documentation note will do for avoiding such trobules.

Thanks for quick response.
History
Date User Action Args
2010-04-21 19:56:43iElectricsetmessages: + msg103901
2010-04-21 19:24:19exarkunsetnosy: + exarkun
messages: + msg103893
2010-04-21 19:17:47iElectriccreate