1
0
Fork 0

Office365Transport properties

This commit is contained in:
Pietro Mingo 2022-07-27 10:21:02 +02:00
parent b37fa6e08d
commit f44eb3036f
9 changed files with 142 additions and 24 deletions

View file

@ -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)