Mariano Munarriz
Mariano Munarriz

Reputation: 91

airflow: Email Configuration

I am scheduling a task to send email from Airflow 2.1.1. I have correctly configured the smtp parameters in the airflow.cfg file

smtp_host = mr.my_domain.com
smtp_starttls = False
smtp_ssl = True
smtp_user = email@my_domain.com
smtp_password = ********
smtp_port = 465
smtp_mail_from = email@my_domain.com
smtp_timeout = 30
smtp_retry_limit = 5

If I test the task from the cli, the emails are sent correctly but I get the following alert message:

..../lib/python3.6/site-packages/airflow/utils/email.py:101 PendingDeprecationWarning: Fetching SMTP credentials from configuration variables will be deprecated in a future release. Please set credentials using a connection instead.

From the GUI the message is:

INFO - Marking task as FAILED.

So I am trying to create a connection as stated in the documentation:

https://airflow.apache.org/docs/apache-airflow/stable/howto/email-config.html

To configure SMTP credentials, create a connection called smtp_default, or choose a custom connection name and set it in email_conn_id.

But when creating a new connection, SMTP is not present among the options.

I hope you can give me a hand, thank you very much in advance.

Upvotes: 3

Views: 8243

Answers (1)

Elad Kalif
Elad Kalif

Reputation: 15961

The docs about email configurations were updated recently by this PR. Since you are viewing the stable version of the docs it's not reflected there until the next Airflow version release.

If you do not want to store the SMTP credentials in the config or in the environment variables, you can create a connection called smtp_default, or choose a custom connection name and set the email_conn_id with it's name in the configuration & store SMTP username-password in it. Other SMTP settings like host, port etc always gets picked up from the configuration only. The connection can be of any type (for example 'HTTP connection').

I think what possibly confuse you is the change made in PR added the :

# Email connection to use

email_conn_id = smtp_default

to airflow.cfg this was done since there are several services that can send emails (smtp/SES/Sendgrid setc..) it needed to be standardized.

Upvotes: 4

Related Questions