Skip to main content

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:

  1. Add the module into the INSTALLED_APPS

    INSTALLED_APPS = [
        ...
        'gmailapi_backend',
        ...
    ]
    
  2. Set the email backend

    EMAIL_BACKEND = 'gmailapi_backend.mail.GmailBackend'
    
  3. 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.

This package includes the script linked in the documentation above, which simplifies the setup of the API credentials. The following outlines the key steps:

  1. Create a project in the Google developer console, https://console.cloud.google.com/
  2. Enable the Gmail API
  3. Create OAuth 2.0 credentials
  4. 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

django_gmailapi_backend-0.3.3.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_gmailapi_backend-0.3.3-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file django_gmailapi_backend-0.3.3.tar.gz.

File metadata

  • Download URL: django_gmailapi_backend-0.3.3.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for django_gmailapi_backend-0.3.3.tar.gz
Algorithm Hash digest
SHA256 6cfa2042478027b5fb70cd313de2ef06d75806a64d06c31b02e93a102a928ed0
MD5 d9583157248722eee3bbb9f73e6ac2df
BLAKE2b-256 58d1429f440d4f209346f450b31980c3de09b0b7bd155cf7ca068a7cdf1b614a

See more details on using hashes here.

File details

Details for the file django_gmailapi_backend-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for django_gmailapi_backend-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3f6f853b1fb1cff518b452cd74db72d0c629a115c432d1efe714a865cae12a43
MD5 0e77a7f8edb744f8debc3f798f472203
BLAKE2b-256 a0cd07b903b48e43598531b46284f8426cea5c2f9673ca2ba211a3ed2eafc84e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page