Skip to main content

Django Azure Communication Email

Unit tests PyPI version Python Django

A Django email backend for Azure Communication Email service.

Installation

Run the following on your system:

pip install django-azure-communication-email

Then, add these settings to your Django settings.py:

EMAIL_BACKEND = 'django_azure_communication_email.EmailBackend'

AZURE_COMMUNICATION_CONNECTION_STRING = '...'
# OR
AZURE_KEY_CREDENTIAL = '...'
AZURE_COMMUNICATION_ENDPOINT = '...'

If you prefer to use Azure Active Directory authentication, you can use the following settings.py instead:

EMAIL_BACKEND = 'django_azure_communication_email.EmailBackend'

AZURE_COMMUNICATION_ENDPOINT = '...'

# Note: make sure to set the following environment variables:
# AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET

Now, when you use django.core.mail.send_mail, Azure Communication Email service will send the messages by default.

Configuring Retry Policy

By default, the Azure SDK will retry failed requests with exponential backoff (up to 10 total retries). This can cause blocking issues when rate limits are hit, as workers may wait for extended periods (an hour or more) trying to send emails.

You can customize the retry behavior by configuring a RetryPolicy in your settings.py:

from azure.core.pipeline.policies import RetryPolicy

# Example 1: Disable retries completely (fail immediately)
AZURE_COMMUNICATION_RETRY_POLICY = RetryPolicy.no_retries()

# Example 2: Reduce retries for faster failure (3 retries instead of 10)
AZURE_COMMUNICATION_RETRY_POLICY = RetryPolicy(
    retry_total=3,
    retry_backoff_factor=0.4,  # Shorter backoff time
)

# Example 3: Increase retries for better reliability
AZURE_COMMUNICATION_RETRY_POLICY = RetryPolicy(
    retry_total=15,
    retry_backoff_factor=1.0,  # Longer backoff time
    retry_backoff_max=180,     # Max 3 minutes between retries
)

For detailed RetryPolicy configuration options, see the Azure SDK documentation.

Running Tests

To run the tests::

python runtests.py

If you want to debug the tests, just add this file as a python script to your IDE run configuration.

Creating a Release

To create a release:

  • Run poetry version {patch|minor|major} as explained in the docs. This will update the version in pyproject.toml.
  • Commit that change and use git to tag that commit with a version that matches the pattern v*.*.*.
  • Push the tag and the commit (note some IDEs don't push tags by default).

Metadata

Release files for django-azure-communication-email 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-azure-communication-email 1.6.0
File Size Uploaded Provenance Actions
django_azure_communication_email-1.6.0.tar.gz 9.3 kB Without provenance Details for django_azure_communication_email-1.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-azure-communication-email 1.6.0
File Interpreter ABI Platform Actions
django_azure_communication_email-1.6.0-py3-none-any.whl Python 3 none any Details for django_azure_communication_email-1.6.0-py3-none-any.whl

Total release size: 20.4 kB

Release files / django_azure_communication_email-1.6.0.tar.gz

Download URL django_azure_communication_email-1.6.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
972e5952722c04b0de024245411f9f57b7200ff81f7e703df47a6cc3dd4b1af2
BLAKE2b-256 checksum
How to use checksums
2918ff1b01030e0ddec1dd2a3ac0001a16e1527f4650f17022b741c19c9ecde9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.12.3 Linux/6.11.0-1018-azure

Release files / django_azure_communication_email-1.6.0-py3-none-any.whl

Download URL django_azure_communication_email-1.6.0-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bda072e03267ced3757516fecb6e9ebeb42c47928eeeef935f4d7ab3e7e82699
BLAKE2b-256 checksum
How to use checksums
7a862c2de68658b556c326ed46b035c5ae140e26b97ac366eb7f93d6c361beae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.12.3 Linux/6.11.0-1018-azure

Security for django-azure-communication-email 1.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page