A Django email backend to use the O365 API
Project description
django-o365mail
Installation
Run the following on your system:
pip install django-o365mail
Then, add these settings to your Django settings.py:
EMAIL_BACKEND = 'django_o365mail.backend.O365EmailBackend'
O365_MAIL_CLIENT_ID = 'REPLACE THIS'
O365_MAIL_CLIENT_SECRET = 'REPLACE THIS'
O365_MAIL_TENANT_ID = 'REPLACE THIS'
Mail can then be sent using the Django mail functions, as described here.
Optional settings
Mailbox
This module uses the python-o365
library, which is also slightly customizable. Because of this you can define kwargs to be used when opening the mailbox. As an example:
O365_MAIL_MAILBOX_KWARGS = {'resource': 'o365mailbox@domain.com'}
... which will be passed to the mailbox() function like this:
account = O365.Account(credentials, auth_flow_type='credentials', tenant_id=self.tenant_id)
mailbox = account.mailbox(**O365_MAIL_MAILBOX_KWARGS)
Other
O365_MAIL_REPLACE_LINE_ENDINGS
(default:True
)
Replaces line endings with an HTML line break (<br />
) when emails are sent in plain text.O365_MAIL_SAVE_TO_SENT
(default:False
)
Saves sent emails to the 'Sent' folder.
Sandbox
Create a file called settings_secret.py
under the sandbox/sandbox
directory (same directory as settings.py
) with the settings as described above, except for the EMAIL_BACKEND
. It could look like this:
O365_MAIL_CLIENT_ID = 'REPLACE THIS'
O365_MAIL_CLIENT_SECRET = 'REPLACE THIS'
O365_MAIL_TENANT_ID = 'REPLACE THIS'
Then, if needed, add settings to settings.py
.
To be able to make changes to this module, run the following command to install this module in editable mode:
pip install -e ./
And run the sandbox server:
cd sandbox && python manage.py runserver
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_o365mail-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d61542a68638edf9e96390e190386a0a479f863860051ac4f76292082e9a69a |
|
MD5 | ede8b8238e5de4e2615eb55dab0ba86a |
|
BLAKE2b-256 | 867dc8b41475f652a8006d6034d76d1bdc93f6e27e99d13700ce675bcda381f5 |