{"id":1330,"library":"apache-airflow-providers-smtp","title":"Apache Airflow SMTP Provider","description":"The `apache-airflow-providers-smtp` package provides the SmtpHook, enabling Apache Airflow to send emails using SMTP. This is essential for features like email notifications in DAGs via the `EmailOperator`. The current version is 2.4.4, with releases typically synchronized with major Airflow releases or as needed for bug fixes and improvements.","status":"active","version":"2.4.4","language":"en","source_language":"en","source_url":"https://github.com/apache/airflow/tree/main/airflow/providers/smtp","tags":["airflow","provider","email","smtp","notification"],"install":[{"cmd":"pip install apache-airflow-providers-smtp","lang":"bash","label":"Install SMTP Provider"}],"dependencies":[{"reason":"This is an Airflow provider and requires a compatible version of Apache Airflow core.","package":"apache-airflow","optional":false}],"imports":[{"note":"This hook provides the underlying SMTP client functionality.","symbol":"SmtpHook","correct":"from airflow.providers.smtp.hooks.smtp import SmtpHook"},{"note":"The EmailOperator is part of Airflow core, not directly provided by this package, but relies on this provider for SMTP functionality.","wrong":"from airflow.providers.smtp.operators.email import EmailOperator","symbol":"EmailOperator","correct":"from airflow.operators.email import EmailOperator"}],"quickstart":{"code":"from airflow.operators.email import EmailOperator\nfrom airflow.models.dag import DAG\nfrom datetime import datetime\n\n# NOTE: For this DAG to send emails, an 'smtp_default' connection\n# must be configured in Airflow (Admin -> Connections) or via airflow.cfg.\n# The apache-airflow-providers-smtp package provides the SmtpHook that EmailOperator uses.\n\nwith DAG(\n    dag_id='simple_email_notification',\n    start_date=datetime(2023, 1, 1),\n    schedule_interval=None,\n    catchup=False,\n    tags=['email_example'],\n) as dag:\n    send_test_email = EmailOperator(\n        task_id='send_test_email',\n        to='your_recipient@example.com', # Replace with a valid email address\n        subject='Airflow Test Email from SMTP Provider',\n        html_content='<h3>Hello from Airflow!</h3><p>This email confirms your SMTP provider is working.</p>',\n        conn_id='smtp_default', # This connection ID should be configured\n    )","lang":"python","description":"This quickstart demonstrates a basic Airflow DAG that uses the `EmailOperator` to send an email. The `apache-airflow-providers-smtp` package must be installed, and an 'smtp_default' connection configured in Airflow for this to function correctly. This provider enables the underlying SMTP communication."},"warnings":[{"fix":"Configure the 'smtp_default' connection in Airflow with valid SMTP server details. Ensure 'ssl_enable' or 'starttls_enable' are correctly set based on your SMTP server.","message":"The `EmailOperator` (and other email features) critically depend on a properly configured `smtp_default` connection in Airflow. This connection must be set up in the Airflow UI (Admin -> Connections) or in `airflow.cfg` with the correct host, port, authentication, and TLS/SSL settings. Without it, email tasks will fail with connection errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your Airflow environment is running on Python 3.10 or newer. Upgrade Python if necessary, or use a virtual environment with the correct Python version.","message":"This provider package requires Python >= 3.10. Installing it in environments with older Python versions will lead to installation errors or runtime incompatibilities.","severity":"gotcha","affected_versions":"All versions >= 2.0.0"},{"fix":"Always ensure the `apache-airflow-providers-smtp` package is installed in your Airflow environment alongside Airflow core. Use `pip install apache-airflow-providers-smtp`.","message":"While the `EmailOperator` is part of Airflow core, its ability to send emails via SMTP relies entirely on the `apache-airflow-providers-smtp` package being installed. If the provider is missing, `EmailOperator` tasks will typically fail silently or with an error indicating a missing dependency or an inability to find a suitable hook.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}