Email backend for Django which sends email via the Gmail API
Project description
Django Gmail API backend
Email backend for Django which sends email via the Gmail API
The simple SMTP protocol is disabled by default for Gmail users, since this is included in the Less Secure Apps (LSA) category. The advice is to use SMTP+OAuth or to use the Gmail API directly. This package implements the second option as a Django email backend.
Installation
Install the package
pip install django-gmailapi-backend
Configuration
In your settings.py
:
-
Add the module into the
INSTALLED_APPS
INSTALLED_APPS = [ ... 'gmailapi_backend', ... ]
-
Set the email backend
EMAIL_BACKEND = 'gmailapi_backend.mail.GmailBackend'
-
Define the configuration parameters from your Gmail developer account (see next section)
GMAIL_API_CLIENT_ID = 'client_id' GMAIL_API_CLIENT_SECRET = 'client_secret' GMAIL_API_REFRESH_TOKEN = 'refresh_token'
Configure the Gmail credentials
For using this package you need to obtain the OAuth credentials for a valid Gmail account.
- More information on the Gmail API: https://developers.google.com/gmail/api/guides/sending
- OAuth credentials for sending emails: https://github.com/google/gmail-oauth2-tools/wiki/OAuth2DotPyRunThrough
This package includes the script linked in the documentation above, which simplifies the setup of the API credentials. The following outlines the key steps:
- Create a project in the Google developer console, https://console.cloud.google.com/
- Enable the Gmail API
- Create OAuth 2.0 credentials
- Create a valid
refresh_token
using the helper script included in the package:gmail_oauth2 --generate_oauth2_token \ --client_id="<client_id>" \ --client_secret="<client_secret>" \ --scope="https://www.googleapis.com/auth/gmail.send"
Project details
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
File details
Details for the file django-gmailapi-backend-0.3.2.tar.gz
.
File metadata
- Download URL: django-gmailapi-backend-0.3.2.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91ac49fd92afa03e90edd4f16419484e10a53f39a9c26d9596c6e725cbc7f4b3 |
|
MD5 | 9c6a4d8f3ac74f99eb5e510aca704061 |
|
BLAKE2b-256 | fe2414f3746c885259d0490d4c91fce828eebbc4fb40e097eb4db0787425612f |
File details
Details for the file django_gmailapi_backend-0.3.2-py3-none-any.whl
.
File metadata
- Download URL: django_gmailapi_backend-0.3.2-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ae335e76b028c64eefe0ad1752f53e6fc88b55191f82365a3ef07e0840722c1 |
|
MD5 | 887f13d2eb91219f1ad14ae3a6266885 |
|
BLAKE2b-256 | 6034f1495a38ad91c0546062f82c71b748ed7c1af8ba152616f4d28ec4f3444f |