Revert "mail headers decoding function now returns completed array instead of single variable"
This reverts commit 51c9221822
.
This commit is contained in:
parent
51c9221822
commit
52c76223a9
|
@ -283,23 +283,13 @@ class Mail():
|
||||||
typ, data = self.imap.fetch(num, '(RFC822)')
|
typ, data = self.imap.fetch(num, '(RFC822)')
|
||||||
raw_mail = data[0][1]
|
raw_mail = data[0][1]
|
||||||
mail=email.message_from_bytes(raw_mail)
|
mail=email.message_from_bytes(raw_mail)
|
||||||
h=email.header.decode_header(mail.get('Subject'))
|
subject = mail.get('Subject')
|
||||||
|
h=email.header.decode_header(subject)
|
||||||
if (h[0][1] != "unknown-8bit"):
|
if (h[0][1] != "unknown-8bit"):
|
||||||
SUBJ = h[0][0].decode(h[0][1]) if h[0][1] else h[0][0]
|
msg = h[0][0].decode(h[0][1]) if h[0][1] else h[0][0]
|
||||||
else:
|
else:
|
||||||
SUBJ = "Unknown charset"
|
msg = "Unknown charset"
|
||||||
h=email.header.decode_header(mail.get('From'))
|
print(msg)
|
||||||
if (h[0][1] != "unknown-8bit"):
|
|
||||||
FROM = h[0][0].decode(h[0][1]) if h[0][1] else h[0][0]
|
|
||||||
else:
|
|
||||||
FROM = "Unknown charset"
|
|
||||||
h=email.header.decode_header(mail.get('Date'))
|
|
||||||
if (h[0][1] != "unknown-8bit"):
|
|
||||||
DATE = h[0][0].decode(h[0][1]) if h[0][1] else h[0][0]
|
|
||||||
else:
|
|
||||||
DATE = "Unknown charset"
|
|
||||||
output = [FROM, SUBJ, DATE]
|
|
||||||
return output
|
|
||||||
except:
|
except:
|
||||||
print("Unable to get mail data")
|
print("Unable to get mail data")
|
||||||
return "ERROR"
|
return "ERROR"
|
||||||
|
@ -323,7 +313,7 @@ def mail_check():
|
||||||
mail_count = "ERROR"
|
mail_count = "ERROR"
|
||||||
else:
|
else:
|
||||||
mail_count += m.checkMail()
|
mail_count += m.checkMail()
|
||||||
print(m.parseMail())
|
m.parseMail()
|
||||||
else:
|
else:
|
||||||
mail_count = "CONNECTION_ERROR"
|
mail_count = "CONNECTION_ERROR"
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue