Airflow-无需凭据即可使用office365配置smtp

问题描述 投票:0回答:1

当任务/DAG 失败时,我想向某人发送电子邮件,但这不起作用。我们在组织内使用 Office365 来实现此目的,并且不需要使用凭据用户或密码进行身份验证,因为在其他正在运行的项目中没有这样做。我们正在使用最新发布的 Airflow 版本:2.1.4

我尝试过气流配置中的配置:

[email]
email_backend = airflow.utils.email.send_email_smtp
email_conn_id = smtp_default
default_email_on_retry = True
default_email_on_failure = True

[smtp]
smtp_host = <the smtp host(Office365)>
smtp_starttls = True
smtp_ssl = False
smtp_port = 25
smtp_mail_from = <the from email>
smtp_timeout = 30
smtp_retry_limit = 5

当我尝试此操作时,当任务失败时,我会在气流日志中收到以下错误:

WARNING - section/key [smtp/smtp_user] not found in config
...
ERROR - Failed to send email to: ['<my email>']

因此,我想如果我在配置中使用这些选项,我需要有一个用户。

日志中还有这样的信息:

PendingDeprecationWarning: Fetching SMTP credentials from configuration variables will be deprecated in a future release. Please set credentials using a connection instead.

我一直在查看这个气流文档: https://airflow.apache.org/docs/apache-airflow/stable/howto/email-config.html

但这并不能帮助我理解如何建立与 Office365 的 smtp 服务器的连接。问题还在于我没有用户或密码。我可能会得到它们,但由于在其他正在运行的项目中没有它们也能工作,所以我希望做类似的事情。

有人在这件事上有一些指导吗?

谢谢你

email smtp office365 airflow
1个回答
1
投票

我有两个项目设置了具有授权的 SMTP,只需按照手动设置即可工作。我有一个新客户,他们的邮件中继没有用户/密码身份验证。他们的系统配置设置为空字符串,如下所示:

它将在日志中留下 PendingDeprecationWarning

[smtp]
...
smtp_starttls = False
smtp_ssl = False
smtp_user =
smtp_password =
© www.soinside.com 2019 - 2024. All rights reserved.