Email Configuration

Airflow sends task emails through the function set in [email] email_backend. By default, email is sent over SMTP by the SMTP provider (apache-airflow-providers-smtp). To set up the SMTP server and its credentials, see Email backend and SMTP Connection.

The [email] section also sets the connection, sender and message templates used for any backend:

[email]
email_backend = airflow.utils.email.send_email_smtp
email_conn_id = smtp_default
from_email = "John Doe <johndoe@example.com>"
subject_template = /path/to/my_subject_template_file
html_content_template = /path/to/my_html_content_template_file

The templates use Jinja and can access the task’s information, for example {{ti.log_url}}.

Note

The functions in airflow.utils.email are deprecated and now live in airflow.providers.smtp.utils.emailer. Only the Python imports moved: keep email_backend set to airflow.utils.email.send_email_smtp. Airflow treats that value as “send with SmtpNotifier”, which reads all SMTP settings from the Connection. Any other value, including the provider path, calls that function instead, and the SMTP provider’s function reads the server settings from [smtp].

To send email through another service, set email_backend to a backend from another provider; see Email backends.

Was this entry helpful?