气流:电子邮件配置

airflow: Email Configuration

我正在安排一项从 Airflow 2.1.1 发送电子邮件的任务。 我已经在 airflow.cfg 文件

中正确配置了 smtp 参数
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

如果我从 cli 测试任务,电子邮件会正确发送,但我会收到以下警告消息:

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

来自 GUI 的消息是:

INFO - Marking task as FAILED.

所以我正在尝试创建一个连接,如文档中所述:

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

要配置 SMTP 凭据,请创建一个名为 smtp_default 的连接,或者选择一个自定义连接名称并在 email_conn_id 中进行设置。

但是在创建新连接时,选项中没有 SMTP。

希望您能帮帮我,在此先感谢您。

有关电子邮件配置的文档最近由 PR 更新。由于您正在查看文档的稳定版本,因此直到下一个 Airflow 版本发布时才会反映出来。

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').

我认为可能让您感到困惑的是 PR 中所做的更改添加了 :

# Email connection to use

email_conn_id = smtp_default

airflow.cfg 之所以这样做是因为有多种服务可以发送电子邮件(smtp/SES/Sendgrid setc..)它需要标准化。