-1

Based on the documentation on the email.getaddresses() module, I would expect getaddresses('"John Doe" <johndoe@mail.com>') to return:

[('John Doe', 'johndoe@mail.com')]

but what it returns (under Python 3.3) is:

[('', ', J, o, h, n, , D, o, e, '), ('', ''), ('', ''), ('', 'j'), ('', 'o'), ('', 'h'), ('', 'n'), ('', 'd'), ('', 'o'), ('', 'e'), ('', '@'), ('', 'm'), ('', 'a'), ('', 'i'), ('', 'l'), ('', '.'), ('', 'c'), ('', 'o'), ('', 'm'), ('', '')]

which is a little less than optimally useful.

What gives?

falsetru
  • 357,413
  • 63
  • 732
  • 636
  • Based on http://docs.python.org/dev/library/email.util.html have you compared the behavior of `parseaddr()` and `getaddresses()`? – Jason Aller Mar 23 '14 at 16:09

1 Answers1

0

According to the email.utils.getaddresses documentation, the argument should be a sequence of header field values, not a single string.

>>> import email.utils
>>> email.utils.getaddresses(['"John Doe" <johndoe@mail.com>'])
[('John Doe', 'johndoe@mail.com')]
falsetru
  • 357,413
  • 63
  • 732
  • 636