- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试使用 Airflow 的 EmailOperator
在 trigger_rule.ONE_FAILED
上发送电子邮件并看到错误:
[2019-10-14 13:31:50,604] {configuration.py:206} WARNING - section/key [smtp/smtp_user] not found in config
Traceback (most recent call last):
File "/bin/airflow", line 27, in <module>
[ args.func(args)
File "/usr/lib/python2.7/site-packages/airflow/bin/cli.py", line 392, in run
pool=args.pool,
File "/usr/lib/python2.7/site-packages/airflow/utils/db.py", line 50, in wrapper
result = func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/airflow/models.py", line 1493, in _run_raw_task
result = task_copy.execute(context=context)
File "/usr/lib/python2.7/site-packages/airflow/operators/email_operator.py", line 64, in execute
send_email(self.to, self.subject, self.html_content, files=self.files, cc=self.cc, bcc=self.bcc, mime_subtype=self.mime_subtype)
File "/usr/lib/python2.7/site-packages/airflow/utils/email.py", line 44, in send_email
return backend(to, subject, html_content, files=files, dryrun=dryrun, cc=cc, bcc=bcc, mime_subtype=mime_subtype)
File "/usr/lib/python2.7/site-packages/airflow/utils/email.py", line 87, in send_email_smtp
send_MIME_email(SMTP_MAIL_FROM, recipients, msg, dryrun)
File "/usr/lib/python2.7/site-packages/airflow/utils/email.py", line 109, in send_MIME_email
s.starttls()
File "/usr/lib64/python2.7/smtplib.py", line 643, in starttls
raise SMTPException("STARTTLS extension not supported by server.")
smtplib.SMTPException: STARTTLS
没有更改默认的airflow.cfg
(访问网络服务器的基本密码验证除外)并且电子邮件部分看起来像
[email]
email_backend = airflow.utils.email.send_email_smtp
[smtp]
# If you want airflow to send emails on retries, failure, and you want to use
# the airflow.utils.email.send_email_smtp function, you have to configure an
# smtp server here
smtp_host = localhost
smtp_starttls = True
smtp_ssl = False
# Uncomment and set the user/pass settings if you want to use SMTP AUTH
# smtp_user = airflow
# smtp_password = airflow
smtp_port = 25
smtp_mail_from = airflow@example.com
查看cfg文件中的端口,好像是open and listening...
[rvillanueva@mapr001 queensetl_airflow]$ netstat -plnt | grep ':25'
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp6 0 0 ::1:25 :::* LISTEN -
...而且我能够对同一台机器 (CentOS 7) 上运行的其他进程使用 linux sendmail
bash 命令。
有人知道这里会发生什么或任何进一步的调试提示吗?
最佳答案
在 airflow 用户邮件列表和上面显示的错误跟踪的帮助下,解决这个问题的方法是设置 smtp_starttls = False
。
使用类似...的脚本进行测试
# Import smtplib for the actual sending function
import smtplib
from email.mime.text import MIMEText
send_to = 'myaddress@co.org'
msg = MIMEText('Hello World')
msg['Subject'] = 'Test Airflow Email'
msg['From'] = 'airflow@example.com'
msg['To'] = send_to
# SMTP Send
s = smtplib.SMTP('localhost')
s.starttls() # Try commenting out this line and see if you get a different error
s.sendmail(me, [send_to], msg.as_string())
s.quit()
看到了同样的错误,并且能够通过注释掉 s.starttls()
行来摆脱它。所以现在我的 airflow.cfg 文件看起来像...
[smtp]
# If you want airflow to send emails on retries, failure, and you want to use
# the airflow.utils.email.send_email_smtp function, you have to configure an
# smtp server here
smtp_host = localhost
#smtp_starttls = True
smtp_starttls = False
smtp_ssl = False
# Uncomment and set the user/pass settings if you want to use SMTP AUTH
# smtp_user = airflow
# smtp_password = airflow
smtp_port = 25
smtp_mail_from = airflow@example.com
并且电子邮件提醒似乎工作正常。
关于 Airflow EmailOperator 抛出 "smtplib.SMTPNotSupportedError: STARTTLS extension not supported by server"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58386075/
尝试使用 Airflow 的 EmailOperator 在 trigger_rule.ONE_FAILED 上发送电子邮件并看到错误: [2019-10-14 13:31:50,604] {conf
我正在尝试使用亚马逊价格跟踪器的 smtp 模块发送带有 gmail 的电子邮件。几天前,它工作得很好,但今天它出现了这个错误: File "C:\Users\61409\AppData\L
我是 Python 新手,尝试使用 Python 3.7 发送电子邮件。 我指的是以下 python 网页来组合我的代码。 https://docs.python.org/3.7/library/em
我是一名优秀的程序员,十分优秀!