This commit is contained in:
Thomas Forgione 2019-02-22 10:54:30 +01:00
parent 4fb746a1d7
commit 2847ed86f1
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 3 additions and 2 deletions

View File

@ -27,15 +27,16 @@ def process_mailbox(mailbox, to = None):
print("ERROR getting message", num)
return False
msg = email.message_from_string(data[0][1].decode())
msg = email.message_from_bytes(data[0][1])
if to is not None:
print('To: ', to)
print('From:', msg['From'])
subject = decode_mime_words(msg['Subject'])
print('Subject: %s' % decode_mime_words(msg['Subject']))
print('Subject: %s' % subject)
date_tuple = email.utils.parsedate_tz(msg['Date'])
if date_tuple:
local_date = datetime.datetime.fromtimestamp(email.utils.mktime_tz(date_tuple))