1fanwang opened a new pull request, #66764:
URL: https://github.com/apache/airflow/pull/66764

   Closes #34554.
   
   ## What
   
   `airflow.utils.email.send_mime_email` reads `login` and `password` from the 
SMTP connection but ignores `host`, `port`, and the connection `extra`. So an 
`Airflow → Connections → smtp_default` row whose host/port differ from `[smtp]` 
config is silently overridden by the config values, and there's no way to 
express SMTP-server options like `disable_tls` / `disable_ssl` / `timeout` / 
`retry_limit` per-connection.
   
   PR #54084 switched the lookup to `Connection` but kept reading only 
`login`/`password`. PR #43413 attempted a wider fix but stalled. The underlying 
gap on `main` is still present.
   
   This PR completes the connection plumbing:
   
   - `host`, `port`, and `extra` (`disable_tls`, `disable_ssl`, `timeout`, 
`retry_limit`) now come from the SMTP connection when set, with the `[smtp]` 
config as the fallback.
   - The `extra` schema matches what the SMTP provider's `SmtpHook` already 
accepts, so a single connection object can drive both 
`apache-airflow-providers-smtp` and core `send_mime_email`.
   
   Connection values override config; absent values keep the config fallback. 
No behavior change when the SMTP connection has no host (the most common 
deployment shape).
   
   ## Tests
   
   `airflow-core/tests/unit/utils/test_email.py`:
   
   - `test_send_mime_conn_host_port_override_config` — connection sets host + 
port, config is ignored
   - `test_send_mime_conn_extras_timeout_retry` — `timeout` + `retry_limit` 
from extras
   - `test_send_mime_conn_extra_disable_tls` — `disable_tls=True` suppresses 
`starttls`
   - `test_send_mime_conn_extra_disable_ssl_false` — `disable_ssl=False` routes 
through `SMTP_SSL` instead of `SMTP`
   - `test_send_mime_conn_empty_host_falls_back_to_config` — connection with no 
host preserves the existing config-driven path
   
   Plus the existing 24 tests in the file. All 30 pass on this branch; the 5 
new ones fail on `main` with the old "host=localhost, port=25" output even with 
the connection set to `conn.example.com:2525`.
   
   ## Newsfragment
   
   `airflow-core/newsfragments/34554.bugfix.rst`.


-- 
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