diff --git a/airflow/config_templates/config.yml b/airflow/config_templates/config.yml index 8b06a68021aa1..e135137aa69ac 100644 --- a/airflow/config_templates/config.yml +++ b/airflow/config_templates/config.yml @@ -2213,21 +2213,6 @@ smtp: type: string example: ~ default: "False" - smtp_user: - description: | - Username to authenticate when connecting to smtp server. - version_added: ~ - type: string - example: "airflow" - default: ~ - smtp_password: - description: | - Password to authenticate when connecting to smtp server. - version_added: ~ - type: string - sensitive: true - example: "airflow" - default: ~ smtp_port: description: | Defines the port number on which Airflow connects to the SMTP server to send email notifications. diff --git a/airflow/config_templates/unit_tests.cfg b/airflow/config_templates/unit_tests.cfg index 42055b9d9c7d0..af32b79f4b0a5 100644 --- a/airflow/config_templates/unit_tests.cfg +++ b/airflow/config_templates/unit_tests.cfg @@ -68,8 +68,6 @@ celery_logging_level = INFO [smtp] # Used as default values for SMTP unit tests -smtp_user = airflow -smtp_password = airflow smtp_mail_from = airflow@example.com [api] diff --git a/airflow/utils/email.py b/airflow/utils/email.py index 31a33337f97df..3a63b4180472b 100644 --- a/airflow/utils/email.py +++ b/airflow/utils/email.py @@ -22,7 +22,6 @@ import os import smtplib import ssl -import warnings from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText @@ -32,7 +31,7 @@ import re2 from airflow.configuration import conf -from airflow.exceptions import AirflowConfigException, AirflowException, RemovedInAirflow3Warning +from airflow.exceptions import AirflowException log = logging.getLogger(__name__) @@ -255,17 +254,7 @@ def send_mime_email( except AirflowException: pass if smtp_user is None or smtp_password is None: - warnings.warn( - "Fetching SMTP credentials from configuration variables will be deprecated in a future " - "release. Please set credentials using a connection instead.", - RemovedInAirflow3Warning, - stacklevel=2, - ) - try: - smtp_user = conf.get("smtp", "SMTP_USER") - smtp_password = conf.get("smtp", "SMTP_PASSWORD") - except AirflowConfigException: - log.debug("No user/password found for SMTP, so logging in with no authentication.") + log.debug("No user/password found for SMTP, so logging in with no authentication.") if not dryrun: for attempt in range(1, smtp_retry_limit + 1): diff --git a/docs/apache-airflow/howto/email-config.rst b/docs/apache-airflow/howto/email-config.rst index c00d959d3bf2d..bc7ea9a1f9d04 100644 --- a/docs/apache-airflow/howto/email-config.rst +++ b/docs/apache-airflow/howto/email-config.rst @@ -96,8 +96,6 @@ You can use the default airflow SMTP backend to send email with SendGrid smtp_host=smtp.sendgrid.net smtp_starttls=False smtp_ssl=False - smtp_user=apikey - smtp_password= smtp_port=587 smtp_mail_from= @@ -108,8 +106,6 @@ Equivalent environment variables looks like AIRFLOW__SMTP__SMTP_HOST=smtp.sendgrid.net AIRFLOW__SMTP__SMTP_STARTTLS=False AIRFLOW__SMTP__SMTP_SSL=False - AIRFLOW__SMTP__SMTP_USER=apikey - AIRFLOW__SMTP__SMTP_PASSWORD= AIRFLOW__SMTP__SMTP_PORT=587 AIRFLOW__SMTP__SMTP_MAIL_FROM= diff --git a/newsfragments/41539.significant.rst b/newsfragments/41539.significant.rst new file mode 100644 index 0000000000000..31a497f4582c1 --- /dev/null +++ b/newsfragments/41539.significant.rst @@ -0,0 +1 @@ +Removed deprecated ``smtp_user`` and ``smtp_password`` configuration parameters from ``smtp`` section. Please use smtp connection (``smtp_default``). diff --git a/tests/core/test_configuration.py b/tests/core/test_configuration.py index 62548a3f26688..94f5bc4c260f7 100644 --- a/tests/core/test_configuration.py +++ b/tests/core/test_configuration.py @@ -1624,7 +1624,6 @@ def test_sensitive_values(): ("database", "sql_alchemy_conn"), ("core", "fernet_key"), ("core", "internal_api_secret_key"), - ("smtp", "smtp_password"), ("webserver", "secret_key"), ("secrets", "backend_kwargs"), ("sentry", "sentry_dsn"), diff --git a/tests/utils/test_email.py b/tests/utils/test_email.py index ea85f635aa37e..bf5f3fc0a18fb 100644 --- a/tests/utils/test_email.py +++ b/tests/utils/test_email.py @@ -28,7 +28,6 @@ import pytest from airflow.configuration import conf -from airflow.exceptions import RemovedInAirflow3Warning from airflow.utils import email from tests.test_utils.config import conf_vars @@ -217,11 +216,7 @@ def test_send_mime_airflow_config(self, mock_smtp, mock_smtp_ssl, monkeypatch): monkeypatch.delenv("AIRFLOW_CONN_SMTP_DEFAULT", raising=False) mock_smtp.return_value = mock.Mock() msg = MIMEMultipart() - with pytest.warns( - RemovedInAirflow3Warning, - match="Fetching SMTP credentials from configuration variables.*deprecated", - ): - email.send_mime_email("from", "to", msg, dryrun=False) + email.send_mime_email("from", "to", msg, dryrun=False) mock_smtp.assert_called_once_with( host=conf.get("smtp", "SMTP_HOST"), port=conf.getint("smtp", "SMTP_PORT"), @@ -229,10 +224,6 @@ def test_send_mime_airflow_config(self, mock_smtp, mock_smtp_ssl, monkeypatch): ) assert not mock_smtp_ssl.called assert mock_smtp.return_value.starttls.called - mock_smtp.return_value.login.assert_called_once_with( - conf.get("smtp", "SMTP_USER"), - conf.get("smtp", "SMTP_PASSWORD"), - ) mock_smtp.return_value.sendmail.assert_called_once_with("from", "to", msg.as_string()) assert mock_smtp.return_value.quit.called