1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-09 22:38:19 +02:00

Actually fixing Python 3 support; verified both IMAP and POP3. Fixes #13 (seriously this time).

This commit is contained in:
Adam Coddington 2014-04-25 16:37:51 -07:00
parent 4002d5c222
commit 3b2d60a903
9 changed files with 145 additions and 16 deletions

View file

@ -1,8 +1,9 @@
import email
from imaplib import IMAP4, IMAP4_SSL
from .base import EmailTransport, MessageParseError
class ImapTransport(object):
class ImapTransport(EmailTransport):
def __init__(self, hostname, port=None, ssl=False):
self.hostname = hostname
self.port = port
@ -29,9 +30,9 @@ class ImapTransport(object):
for key in inbox[0].split():
try:
typ, msg_contents = self.server.fetch(key, '(RFC822)')
message = email.message_from_string(msg_contents[0][1])
message = self.get_email_from_bytes(msg_contents[0][1])
yield message
except email.Errors.MessageParseError:
except MessageParseError:
continue
self.server.store(key, "+FLAGS", "\\Deleted")
self.server.expunge()