mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
Enable folder function for gmail
This commit is contained in:
parent
98942fb584
commit
5042ccc1fe
2 changed files with 10 additions and 8 deletions
|
|
@ -216,7 +216,8 @@ class Mailbox(models.Model):
|
||||||
self.location,
|
self.location,
|
||||||
port=self.port if self.port else None,
|
port=self.port if self.port else None,
|
||||||
ssl=True,
|
ssl=True,
|
||||||
archive=self.archive
|
archive=self.archive,
|
||||||
|
folder=self.folder,
|
||||||
)
|
)
|
||||||
conn.connect(self.username, self.password)
|
conn.connect(self.username, self.password)
|
||||||
elif self.type == 'pop3':
|
elif self.type == 'pop3':
|
||||||
|
|
@ -429,9 +430,9 @@ class Mailbox(models.Model):
|
||||||
if not connection:
|
if not connection:
|
||||||
return
|
return
|
||||||
|
|
||||||
since = self.last_polling
|
# since = self.last_polling
|
||||||
if since is None:
|
# if since is None:
|
||||||
since = now() - timedelta(days=INITIAL_IMPORT_LOOKBACK_DAYS)
|
since = now() - timedelta(days=INITIAL_IMPORT_LOOKBACK_DAYS)
|
||||||
|
|
||||||
for message in connection.get_message_ro(since=since):
|
for message in connection.get_message_ro(since=since):
|
||||||
msg = self.process_incoming_message(message)
|
msg = self.process_incoming_message(message)
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,7 @@ class GmailImapTransport(ImapTransport):
|
||||||
self._connect_oauth(username)
|
self._connect_oauth(username)
|
||||||
except (TypeError, ValueError) as e:
|
except (TypeError, ValueError) as e:
|
||||||
logger.warning("Couldn't do oauth2 because %s" % e)
|
logger.warning("Couldn't do oauth2 because %s" % e)
|
||||||
self.server = self.transport(self.hostname, self.port)
|
super().connect(username, password)
|
||||||
typ, msg = self.server.login(username, password)
|
|
||||||
self.server.select()
|
|
||||||
|
|
||||||
def _connect_oauth(self, username):
|
def _connect_oauth(self, username):
|
||||||
# username should be an email address that has already been authorized
|
# username should be an email address that has already been authorized
|
||||||
|
|
@ -54,4 +52,7 @@ class GmailImapTransport(ImapTransport):
|
||||||
)
|
)
|
||||||
self.server = self.transport(self.hostname, self.port)
|
self.server = self.transport(self.hostname, self.port)
|
||||||
self.server.authenticate('XOAUTH2', lambda x: auth_string)
|
self.server.authenticate('XOAUTH2', lambda x: auth_string)
|
||||||
self.server.select()
|
if self.folder:
|
||||||
|
self.server.select(self.folder)
|
||||||
|
else:
|
||||||
|
self.server.select()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue