气流-使用AWS SES发送电子邮件

时间:2020-06-30 14:56:58

标签: python amazon-web-services email airflow amazon-ses

尝试使用AWS Simple Email Service(SES)从apache airflow发送电子邮件,但返回的错误无法帮助我解决问题。我相信这是SES中的配置问题,但我不确定要更改什么。

一般信息:

  • 新的SES实例,已验证的电子邮件。
  • 在Ubuntu 18.04(本地笔记本电脑)上运行的Airflow 1.10.10。
  • 与EC2实例在单独的AWS账户上的情况相同。
  • 使用运行良好的python运算符运行1个DAG。
  • 发送电子邮件可使用gmail smtp设置和应用密码。

DAG的缩写代码:

...
from airflow.operators.email_operator import EmailOperator
...
email_status = EmailOperator(
        task_id="sending_status_email",
        to="myverifiedemail@mydomain.com",
        subject="Test from SES",
        html_content="Trying to send an email from airflow through SES.",
        dag=dag
)
...

airflow.cfg SMTP设置:

smtp_host = email-smtp.us-east-1.amazonaws.com
smtp_starttls = True
smtp_ssl = False
smtp_user = AWSUSERKEY
smtp_password = PASSWORDFROMAWSSMTP
smtp_port = 587
smtp_mail_from = myverifiedemail@mydomain.com

尝试对starttls,ssl和端口设置进行各种更改时收到错误。

ERROR - (554, b'Transaction failed: Unsupported encoding us_ascii.')
ERROR - STARTTLS extension not supported by server.
ERROR - (SSL: WRONG_VERSION_NUMBER) wrong version number (_ssl.c:852)

1 个答案:

答案 0 :(得分:4)

不确定其他,但是我们今天遇到了这个错误:

[
    dict(
        dict(zip(["id", "name", "text"], list_of_tuples[index])),
        **{"value": value},
    )
    for index, value in enumerate(value_array)
    if not (math.isnan(value))
]

这是类的ERROR - (554, b'Transaction failed: Unsupported encoding us_ascii.') 方法中的默认值,该值无效: https://github.com/apache/airflow/blob/1.10.10/airflow/operators/email_operator.py#L63

您可以通过传递有效值(例如“ utf-8”)来解决该问题:

__init__
相关问题