feat: support Django MAILERS transport aliases #1

Merged
camila merged 1 commit from feat/mailers-forgejo into main 2026-11-06 08:52:18 +01:00
Member

Summary

  • Add NITRO_EMAIL_MAILER to select a configured Django 6.1+ MAILERS transport alias, including SMTP credentials and other OPTIONS.
  • Use the same configured transport for synchronous delivery, queued delivery, retry/admin paths, and nitro_send_emails.
  • Reject missing transport configuration, unknown aliases, and aliases pointing back to Nitro backends without dropping queued messages.
  • Preserve legacy NITRO_EMAIL_BACKEND behavior, current SMTP connection reuse, and per-email transactions. The new alias takes precedence when supplied.
  • Document a working Nitro default mailer plus separate SMTP alias in the README.

Root cause

The current helper constructs the delivery backend directly without the configured alias or its MAILERS[alias]["OPTIONS"]. As a result, migrating SMTP credentials to MAILERS does not configure Nitro's delivery transport. This change uses Django's real mailers registry when the new alias setting is supplied.

Verification

Local Python 3.13.5, isolated environments:

  • Django 5.2.19: 21 passed, 9 skipped.
  • Django 6.0.10: 21 passed, 9 skipped.
  • Django 6.1.3: 29 passed, 1 skipped (independently rerun).
  • SMTP is mocked at the network boundary; tests assert host, port, STARTTLS, username/password and delivery through the real Django mailers registry.
  • Regression tests were executed RED before implementation, then GREEN. Actual management command delivery is covered.
  • Ruff check, Ruff format check and git diff --check: passed.
  • Independent final source review: no blockers.

Compatibility and scope

  • No version bump, dependency changes, migrations, transaction changes, or restored obsolete docs.
  • Existing NITRO_EMAIL_BACKEND configuration remains supported, including an explicitly configured custom legacy backend alongside MAILERS.
  • One global delivery alias, not per-message routing.
  • Django 6.1 tests report existing legacy EMAIL_BACKEND deprecation warnings from test configuration.
  • Other supported Python versions are left to the existing CI matrix; no live SMTP sends were performed.

Final CI result

All 26 push/PR checks passed before merge. The push job for Python 3.14 / Django 5.2 initially failed during checkout because the runner could not connect to Forgejo (git exit 128); it passed on attempt 2. No source changes were needed.

## Summary - Add `NITRO_EMAIL_MAILER` to select a configured Django 6.1+ `MAILERS` transport alias, including SMTP credentials and other `OPTIONS`. - Use the same configured transport for synchronous delivery, queued delivery, retry/admin paths, and `nitro_send_emails`. - Reject missing transport configuration, unknown aliases, and aliases pointing back to Nitro backends without dropping queued messages. - Preserve legacy `NITRO_EMAIL_BACKEND` behavior, current SMTP connection reuse, and per-email transactions. The new alias takes precedence when supplied. - Document a working Nitro default mailer plus separate SMTP alias in the README. ## Root cause The current helper constructs the delivery backend directly without the configured alias or its `MAILERS[alias]["OPTIONS"]`. As a result, migrating SMTP credentials to `MAILERS` does not configure Nitro's delivery transport. This change uses Django's real mailers registry when the new alias setting is supplied. ## Verification Local Python 3.13.5, isolated environments: - Django 5.2.19: 21 passed, 9 skipped. - Django 6.0.10: 21 passed, 9 skipped. - Django 6.1.3: 29 passed, 1 skipped (independently rerun). - SMTP is mocked at the network boundary; tests assert host, port, STARTTLS, username/password and delivery through the real Django mailers registry. - Regression tests were executed RED before implementation, then GREEN. Actual management command delivery is covered. - Ruff check, Ruff format check and `git diff --check`: passed. - Independent final source review: no blockers. ## Compatibility and scope - No version bump, dependency changes, migrations, transaction changes, or restored obsolete docs. - Existing `NITRO_EMAIL_BACKEND` configuration remains supported, including an explicitly configured custom legacy backend alongside `MAILERS`. - One global delivery alias, not per-message routing. - Django 6.1 tests report existing legacy `EMAIL_BACKEND` deprecation warnings from test configuration. - Other supported Python versions are left to the existing CI matrix; no live SMTP sends were performed. ## Final CI result All 26 push/PR checks passed before merge. The push job for Python 3.14 / Django 5.2 initially failed during checkout because the runner could not connect to Forgejo (git exit 128); it passed on attempt 2. No source changes were needed.
feat: support Django MAILERS transport aliases
All checks were successful
Tests / Ruff Linter (pull_request) Successful in 6s
Tests / Ruff Formatter (pull_request) Successful in 6s
Tests / Ruff Linter (push) Successful in 6s
Tests / Ruff Formatter (push) Successful in 6s
Tests / Pytest (Python 3.10, Django 5.2) (pull_request) Successful in 12s
Tests / Pytest (Python 3.11, Django 5.2) (pull_request) Successful in 12s
Tests / Pytest (Python 3.12, Django 5.2) (pull_request) Successful in 13s
Tests / Pytest (Python 3.13, Django 5.2) (pull_request) Successful in 13s
Tests / Pytest (Python 3.14, Django 5.2) (pull_request) Successful in 13s
Tests / Pytest (Python 3.12, Django 6.0) (pull_request) Successful in 13s
Tests / Pytest (Python 3.13, Django 6.0) (pull_request) Successful in 13s
Tests / Pytest (Python 3.14, Django 6.0) (pull_request) Successful in 13s
Tests / Pytest (Python 3.12, Django 6.1) (pull_request) Successful in 13s
Tests / Pytest (Python 3.13, Django 6.1) (pull_request) Successful in 13s
Tests / Pytest (Python 3.14, Django 6.1) (pull_request) Successful in 13s
Tests / Pytest (Python 3.10, Django 5.2) (push) Successful in 12s
Tests / Pytest (Python 3.11, Django 5.2) (push) Successful in 12s
Tests / Pytest (Python 3.12, Django 5.2) (push) Successful in 12s
Tests / Pytest (Python 3.13, Django 5.2) (push) Successful in 13s
Tests / Pytest (Python 3.12, Django 6.0) (push) Successful in 13s
Tests / Pytest (Python 3.13, Django 6.0) (push) Successful in 13s
Tests / Pytest (Python 3.14, Django 6.0) (push) Successful in 14s
Tests / Pytest (Python 3.12, Django 6.1) (push) Successful in 13s
Tests / Pytest (Python 3.13, Django 6.1) (push) Successful in 13s
Tests / Pytest (Python 3.14, Django 6.1) (push) Successful in 13s
Tests / Pytest (Python 3.14, Django 5.2) (push) Successful in 13s
e4a6cb7b53
exler approved these changes 2026-11-06 08:47:31 +01:00
camila merged commit 77fe4d8d7f into main 2026-11-06 08:52:18 +01:00
exler deleted branch feat/mailers-forgejo 2026-11-06 08:54:47 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
majikode/django-nitro-mailer!1
No description provided.