Skip to content

Add support for sending emails through Microsoft Graph - #71565

Merged
dabla merged 1 commit into
apache:mainfrom
rjgoyln:feature/msgraph-email-backend
Sep 9, 2026
Merged

dabla merged 1 commit into
apache:mainfrom
rjgoyln:feature/msgraph-email-backend

Conversation

@rjgoyln

@rjgoyln rjgoyln commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Sending mail from an Office 365 or Outlook cloud mailbox is expected to go through Microsoft Graph, and with EWS gone the SMTP relay into those mailboxes is the last legacy path standing. Airflow could only reach them over SMTP, so a deployment on a Microsoft tenant had no supported way to alert on task failures from its own mailbox.

Change

The Azure provider sends mail through the Graph sendMail endpoint over an existing msgraph connection, covering both places email is configured: [email] email_backend for email_on_failure and email_on_retry, and MSGraphNotifier for the state-change callbacks. The notifier implements async_notify, so it also runs in the triggerer.

from_email selects the mailbox to send from, and Graph addresses that mailbox in the request path — hence the parseaddr, since the option is conventionally configured as Display name <user@example.com>, the form SMTP and SES accept. Attachments ride inline in the request body rather than through an upload session, which is what bounds them at 3 MB.

The email backend contract is synchronous while the Graph hook is async-only. The sync entry point therefore runs the coroutine on its own loop and closes the request adapter before that loop goes away; the cached adapter would otherwise outlive asyncio.run bound to a closed loop and break the next email.

closes: #71541


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

Generated-by: Claude Code (Opus 5) following the guidelines

Comment thread airflow-core/docs/howto/email-config.rst
@rjgoyln
rjgoyln force-pushed the feature/msgraph-email-backend branch from 486cbf8 to 6e6f3ef Compare August 14, 2026 18:18
@rjgoyln
rjgoyln marked this pull request as ready for review August 14, 2026 18:49
@rjgoyln
rjgoyln requested a review from dabla as a code owner August 14, 2026 18:49
Comment thread providers/microsoft/azure/src/airflow/providers/microsoft/azure/emailer.py Outdated
Comment thread docs/spelling_wordlist.txt Outdated
Comment thread providers/microsoft/azure/src/airflow/providers/microsoft/azure/emailer.py Outdated
@dabla

dabla commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

I will try to review this PR tomorrow as I may have some remarks, but I like this, very nice and needed addition!

Comment thread providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py Outdated
@rjgoyln
rjgoyln force-pushed the feature/msgraph-email-backend branch from 28ec0c9 to eed625f Compare September 7, 2026 16:30
Comment thread providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py Outdated
@rjgoyln
rjgoyln force-pushed the feature/msgraph-email-backend branch 2 times, most recently from e2b1fce to 0e00ef1 Compare September 8, 2026 16:13
Sending mail from an Office 365 or Outlook cloud mailbox is expected to go
through Microsoft Graph, and with EWS gone the SMTP relay into those mailboxes
is the last legacy path standing. Airflow could only reach them over SMTP, so a
deployment on a Microsoft tenant had no supported way to alert on task failures
from its own mailbox.
@rjgoyln
rjgoyln force-pushed the feature/msgraph-email-backend branch from 0e00ef1 to cb94f03 Compare September 8, 2026 16:39
@dabla
dabla merged commit 754ba31 into apache:main Sep 9, 2026
84 checks passed
@dabla

dabla commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Congratulations @rjgoyln, nice work on this PR as this was a most needed feature especially with notifications.

@rjgoyln

rjgoyln commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Really appreciate it!

imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
Sending mail from an Office 365 or Outlook cloud mailbox is expected to go
through Microsoft Graph, and with EWS gone the SMTP relay into those mailboxes
is the last legacy path standing. Airflow could only reach them over SMTP, so a
deployment on a Microsoft tenant had no supported way to alert on task failures
from its own mailbox.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for sending emails on Outlook 365 via Microsoft Graph

3 participants