mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
fix and documentation
This commit is contained in:
parent
b39299692a
commit
9f314a38f2
3 changed files with 38 additions and 12 deletions
|
|
@ -40,12 +40,15 @@ class Office365Transport(EmailTransport):
|
|||
self.mailbox_folder = self.mailbox.get_folder(folder_name=self.folder)
|
||||
|
||||
def get_message(self, condition=None):
|
||||
archive_folder = None
|
||||
if self.archive:
|
||||
self.mailbox.create_child_folder(self.archive)
|
||||
archive_folder = self.mailbox.get_folder(folder_name=self.archive)
|
||||
if not archive_folder:
|
||||
archive_folder = self.mailbox.create_child_folder(self.archive)
|
||||
|
||||
for message in self.mailbox.get_messages(order_by='receivedDateTime'):
|
||||
for o365message in self.mailbox_folder.get_messages(order_by='receivedDateTime'):
|
||||
try:
|
||||
mime_content = message.get_mime_content()
|
||||
mime_content = o365message.get_mime_content()
|
||||
message = self.get_email_from_bytes(mime_content)
|
||||
|
||||
if condition and not condition(message):
|
||||
|
|
@ -55,9 +58,9 @@ class Office365Transport(EmailTransport):
|
|||
except MessageParseError:
|
||||
continue
|
||||
|
||||
if self.archive:
|
||||
message.copy(self.archive)
|
||||
if self.archive and archive_folder:
|
||||
o365message.copy(archive_folder)
|
||||
|
||||
message.delete()
|
||||
o365message.delete()
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -40,12 +40,15 @@ class Office365Transport(EmailTransport):
|
|||
self.mailbox_folder = self.mailbox.get_folder(folder_name=self.folder)
|
||||
|
||||
def get_message(self, condition=None):
|
||||
archive_folder = None
|
||||
if self.archive:
|
||||
self.mailbox.create_child_folder(self.archive)
|
||||
archive_folder = self.mailbox.get_folder(folder_name=self.archive)
|
||||
if not archive_folder:
|
||||
archive_folder = self.mailbox.create_child_folder(self.archive)
|
||||
|
||||
for message in self.mailbox.get_messages(order_by='receivedDateTime'):
|
||||
for o365message in self.mailbox_folder.get_messages(order_by='receivedDateTime'):
|
||||
try:
|
||||
mime_content = message.get_mime_content()
|
||||
mime_content = o365message.get_mime_content()
|
||||
message = self.get_email_from_bytes(mime_content)
|
||||
|
||||
if condition and not condition(message):
|
||||
|
|
@ -55,9 +58,9 @@ class Office365Transport(EmailTransport):
|
|||
except MessageParseError:
|
||||
continue
|
||||
|
||||
if self.archive:
|
||||
message.copy(self.archive)
|
||||
if self.archive and archive_folder:
|
||||
o365message.copy(archive_folder)
|
||||
|
||||
message.delete()
|
||||
o365message.delete()
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ POP3 and IMAP as well as local file-based mailboxes.
|
|||
POP3 ``pop3://`` Can also specify SSL with ``pop3+ssl://``
|
||||
IMAP ``imap://`` Can also specify SSL with ``imap+ssl://`` or STARTTLS with ``imap+tls``; additional configuration is also possible: see :ref:`pop3-and-imap-mailboxes` for details.
|
||||
Gmail IMAP ``gmail+ssl://`` Uses OAuth authentication for Gmail's IMAP transport. See :ref:`gmail-oauth` for details.
|
||||
Office365 API``office365://`` Uses OAuth authentication for Office365 API transport. See :ref:`office365-oauth` for details.
|
||||
Maildir ``maildir://``
|
||||
Mbox ``mbox://``
|
||||
Babyl ``babyl://``
|
||||
|
|
@ -115,6 +116,25 @@ Build your URI accordingly::
|
|||
gmail+ssl://youremailaddress%40gmail.com:oauth2@imap.gmail.com?archive=Archived
|
||||
|
||||
|
||||
.. _office365-oauth:
|
||||
Office 365 API
|
||||
-------------------------------------
|
||||
|
||||
Office 365 allows through the API to read a mailbox with Oauth.
|
||||
The O365_ library is used.
|
||||
|
||||
.. _O365: https://github.com/O365/python-o365
|
||||
.. _configuration: https://github.com/O365/python-o365#authentication
|
||||
|
||||
For the configuration_ you need to register an application and get a client_id, client_secret and tenant_id.
|
||||
|
||||
This implementation uses the client credentials grant flow and the password you specify will be ignored.
|
||||
|
||||
Build your URI accordingly::
|
||||
|
||||
office365://youremailaddress%40yourdomain.com:oauth2@outlook.office365.com?client_id=client_id&client_secret=client_secret&tenant_id=tenant_id&archive=Archived
|
||||
|
||||
|
||||
Local File-based Mailboxes
|
||||
--------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue