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.
pip install django-gsuite-emailINSTALLED_APPS = [
...
'django_gsuite_email',
...
]EMAIL_BACKEND = 'django_gsuite_email.GSuiteEmailBackend'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"Alternatively you can set the JSON string in a env variable and initialize GSUITE_CREDENTIALS_JSON in settings.py
from decouple import config
GSUITE_CREDENTIALS_JSON = config("GSUITE_CREDENTIALS_JSON")
If this is set it will take precedence over GSUITE_CREDENTIALS_FILE
from django.core.mail import send_mail
send_mail(
'Subject here',
'Here is the message.',
'from@example.com',
['to@example.com'],
fail_silently=False,
)