352 |
"""Encode and line-wrap the value of an email header field containing |
"""Encode and line-wrap the value of an email header field containing |
353 |
email addresses.""" |
email addresses.""" |
354 |
|
|
355 |
|
# (cg) It seems that From: names (or perhaps Subject: headers) that contain |
356 |
|
# a UTF8 character before the first space confuse the older python Header() |
357 |
|
# class. This does not appear to be needed in newer python versions, but |
358 |
|
# this little workaround seems to help on 2.7.1 on valstar mga1. |
359 |
|
try: |
360 |
|
unicode(text) |
361 |
|
except UnicodeDecodeError: |
362 |
|
text = text.decode('utf-8') |
363 |
|
|
364 |
return Header( |
return Header( |
365 |
', '.join( |
', '.join( |
366 |
formataddr((header_encode(name), emailaddr)) |
formataddr((header_encode(name), emailaddr)) |