forked from mirror/django-mailbox
Office365Transport properties
This commit is contained in:
parent
b37fa6e08d
commit
f44eb3036f
9 changed files with 142 additions and 24 deletions
|
|
@ -189,6 +189,30 @@ class Mailbox(models.Model):
|
|||
return None
|
||||
return folder[0]
|
||||
|
||||
@property
|
||||
def client_id(self):
|
||||
"""Returns (if specified) the client id for Office365."""
|
||||
client_id = self._query_string.get('client_id', None)
|
||||
if not client_id:
|
||||
return None
|
||||
return client_id[0]
|
||||
|
||||
@property
|
||||
def client_secret(self):
|
||||
"""Returns (if specified) the client secret for Office365."""
|
||||
client_secret = self._query_string.get('client_secret', None)
|
||||
if not client_secret:
|
||||
return None
|
||||
return client_secret[0]
|
||||
|
||||
@property
|
||||
def tenant_id(self):
|
||||
"""Returns (if specified) the tenant id for Office365."""
|
||||
tenant_id = self._query_string.get('tentant_id', None)
|
||||
if not tenant_id:
|
||||
return None
|
||||
return tenant_id[0]
|
||||
|
||||
def get_connection(self):
|
||||
"""Returns the transport instance for this mailbox.
|
||||
|
||||
|
|
@ -224,7 +248,14 @@ class Mailbox(models.Model):
|
|||
)
|
||||
conn.connect(self.username, self.password)
|
||||
elif self.type == 'office365':
|
||||
conn = Office365Transport(self.location)
|
||||
conn = Office365Transport(
|
||||
port=self.port if self.port else None,
|
||||
ssl=True,
|
||||
archive=self.archive,
|
||||
client_id=self.client_id,
|
||||
client_secret=self.client_secret,
|
||||
tenant_id=self.tenant_id
|
||||
)
|
||||
conn.connect(self.username, self.password)
|
||||
elif self.type == 'maildir':
|
||||
conn = MaildirTransport(self.location)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue