R. David Murray added the comment:
Unfortunately the imap module in the stdlib doesn't provide a whole lot in the
way of tools for parsing the imap data, just for sending it back and forth to
the server.
--
___
Python
tom de wulf added the comment:
I do get this data from an IMAP fetch statement, see my code below:
rv, data = imap.fetch(num, "(BODY[HEADER.FIELDS (FROM SUBJECT)])")
if rv != 'OK':
logging.error("Error getting message sender and subject (" +
R. David Murray added the comment:
parseaddr is for parsing the contents of an address header, not for parsing any
additional text. So the correct way to call it is parseaddress('someone
').
In any case, please look in to the new email policies,
New submission from tom de wulf :
Probably a parsing bug in email.utils.parseaddr.
How to recreate:
>>> import email.utils
>>> test = 'Subject: I am a bug [Random]\r\nFrom: someone
>>> \r\n\r\n'
>>> email.utils.parseaddr(test)
('', 'I')
>>>