Send emails via a GSuite Service-account.
Project description
GSuite Email Backend
This package allows to use Django's send_mail
command to send emails through GSuite account.
It requires a serviceaccount credential created in Google coud console,
The crendential file need to have https://www.googleapis.com/auth/gmail.send
scope.
Follow this tutorial to create the credentials file, make sure to add https://www.googleapis.com/auth/gmail.send
scope.
Installation
pip install django-gsuite-email
Quick start
1. Add it to installed apps in setings.py
INSTALLED_APPS = [
...
'django_gsuite_email',
...
]
2. Set the Email EMAIL_BACKEND setting
EMAIL_BACKEND = 'django_gsuite_email.GSuiteEmailBackend'
3. Set location of credentials file.
To do this, either set GSUITE_CREDENTIALS_FILE
environment variable.
OR
set GSUITE_CREDENTIALS_FILE
in settings.py
GSUITE_CREDENTIALS_FILE="/path/to/credentials/file.json"
Note:
GSUITE_CREDENTIALS_FILE
insettings.py
will take precedence over environment variable.
4. Send emails
from django.core.mail import send_mail
send_mail(
'Subject here',
'Here is the message.',
'from@example.com',
['to@example.com'],
fail_silently=False,
)
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
Close
Hashes for djau_gsuite_email-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e119be6c3dbb16012954ad8df7adb678cf9236dc5b5ceb298e31a9a4ae0df47d |
|
MD5 | c5737cf802f06a698296e35b4b620ef4 |
|
BLAKE2b-256 | f959f2259d2efadb5f70103807a3523473b3a4c8a85bb1048891a8e325710346 |