django / django/new-features

Support for OAuth authentication in django.core.mail.backends.smtp.EmailBackend

Open
#196 6 comments 0 reactions 0 assignees View on GitHub
Email Third Party Package
Dominant language
No language data
Stars
188
Forks
7
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [x] I agree to follow Django's Code of Conduct

### Feature Description

Support for the apparently more modern authentication method SASL (X)OAuth 2.0 in django.core.mail.backends.smtp.EmailBackend (or a new SMTP backend with this newer way of authenticating)

### Problem

A lot of providers seems to be turning off support for sending mails using SMTP, in particular with the original authentication method.
from https://github.com/simonrob/email-oauth2-proxy#example-use-cases:
* You need to use an Office 365 email account, but don't get on with Outlook. The email client you like doesn't support OAuth 2.0, which became mandatory for IMAP/POP [in January 2023](https://techcommunity.microsoft.com/t5/exchange-team-blog/basic-authentication-deprecation-in-exchange-online-september/ba-p/3609437) ([September 2024 for personal Hotmail/Outlook accounts](https://support.microsoft.com/en-us/office/modern-authentication-methods-now-needed-to-continue-syncing-outlook-email-in-non-microsoft-email-apps-c5d65390-9676-4763-b41f-d7986499a90d); [late 2027 for O365 SMTP](https://techcommunity.microsoft.com/t5/exchange-team-blog/exchange-online-to-retire-basic-auth-for-client-submission-smtp/ba-p/4114750)).
* You used to use Gmail via IMAP/POP/SMTP with your raw account credentials (i.e., your real password), but cannot do this now that Google has disabled this method, and don't want to use an [App Password](https://support.google.com/accounts/answer/185833) (or cannot enable this option).

### Request or proposal

request

### Additional Details

Implementation specific alternatives could be used per mail provider (e.g like https://pypi.org/project/django-msgraphbackend/ for MS Exchange), but I could not find any "de jure" alternatives for this with comfortably high amount of users.

[Postfix sasl-xoauth2 plugin](https://github.com/tarickb/sasl-xoauth2) has some info regarding what/how

### Implementation Suggestions

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with django.core.mail.backends.smtp.EmailBackend and review how its current authentication flow is structured. Compare the requested SASL XOAuth2 support with the provider-specific alternatives mentioned, then define the supported scope and how completion would be tested for SMTP providers.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
authentication, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.