shivaam opened a new pull request, #74623:
URL: https://github.com/apache/airflow/pull/74623

   Core's email wrapper and the SMTP provider currently own different SMTP 
delivery policies. Sending existing core callers through `SmtpHook` would 
combine a code-ownership migration with changes to configuration, 
authentication, retries and failure handling. This PR prepares the provider 
capability first so that a later core migration can preserve users' existing 
settings and behavior.
   
   Add `airflow.providers.smtp.utils.legacy.send_mime_email`, which accepts an 
already-built MIME message, resolved SMTP settings/credentials, and a lazy 
SSL-context factory. It does not read Airflow configuration or Connections, and 
it adds no dependency. New Dag code should continue using the existing hook, 
operator or notifier.
   
   This is an enabling slice, not the complete core-email migration. Core 
callers, message construction, templates, sender precedence, the configured 
backend, and the modern SMTP hook/operator/notifier are unchanged. Core 
adoption must follow a released provider containing this API, coordinated with 
the release managers, and be validated against installed artifacts rather than 
only a source checkout.
   
   Compatibility intentionally preserves constructor-only disconnection 
retries, ignored partial-recipient refusal, pre-send logging, negative-retry 
no-op behavior, and existing post-construction failure/cleanup semantics. A 
delivery or QUIT failure can occur after server acceptance; a caller retry can 
duplicate mail. This PR does not claim exactly-once delivery or improve these 
policies. Policy improvements require separate review rather than silently 
changing the ownership move.
   
   The compatibility API is public because its intended consumer is in another 
distribution. Approval of that cross-distribution contract is part of this 
review. Future notes about private core patch targets belong in the core 
follow-up, not this provider release.
   
   related: #30530
   
   ## Verification
   
   Verified locally on Python 3.11 at 
`5ff60a1b9f454486cc2715bf21dbf520c949bfd3`, rebased onto 
`9fc4143efc5eba3b0436122ff7505bc516e8f80a`:
   
   - 229 regressions: 99 SMTP, 34 core/processor email, 16 Task SDK email, 77 
SES and 3 SendGrid.
   - 1,012 compatibility/Kubernetes tests passed; 29 expected skips. This 
selection excludes explicitly database-marked tests.
   - New transport: 100% statement/branch coverage (24 statements, 10 
branches). An in-memory negative control that discards the TLS context caused 
three expected test failures; tracked sources were not mutated.
   - Real Mailpit: 22 checks across plain SMTP, STARTTLS, implicit TLS, 
rejected credentials/certificates, outage/recovery, unchanged EmailOperator 
execution and repeated notifier calls. Parsed captures verify Unicode, binary 
attachment and To/Cc/Bcc envelope data.
   - Source distribution and wheel build; installation outside the checkout and 
one real SMTP send from the installed wheel. The import path was asserted to 
belong to the wheel target, not a mounted source package.
   - SMTP-package mypy, full-provider manual type gate, regular/commit hooks, 
documentation builds and spelling passed. Two fresh independent Claude Code 
reviews were reconciled; no remaining P1/P2 findings.
   
   The real-Mailpit checks prove SMTP acceptance and stored MIME/envelope data, 
not delivery to Gmail, spam placement, DNS/MX/SPF/DKIM/DMARC, or a 
scheduler-triggered alert. This is not a full multi-Python or database CI 
matrix. No newsfragment is included, following provider release guidance.
   
   @eladkal could you review this provider-first compatibility boundary as an 
initial step toward the core email migration? In particular, feedback on the 
explicit-input transport API and release ordering would help before preparing 
the separate core-delegation PR.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Codex and Claude Code (independent review)
   
   Generated-by: Codex with Claude Code review, following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---
   
   Drafted-by: Codex (no human review of this description before posting)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to