gpt4 book ai didi

python - Airflow - 使用 AWS SES 发送电子邮件

转载 作者:行者123 更新时间:2023-12-03 16:11:02 25 4
gpt4 key购买 nike

尝试使用 AWS 简单电子邮件服务 (SES) 从 apache Airflow 发送电子邮件,但返回的错误无助于我解决问题。我相信这是 SES 中的配置问题,但我不确定要更改什么。
基本信息:

  • 新的 SES 实例,经过验证的电子邮件。
  • Airflow 1.10.10 在 Ubuntu 18.04(本地笔记本电脑)上运行。
  • 来自单独 AWS 账户上的 EC2 实例的相同情况。
  • 使用运行良好的 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)

    最佳答案

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

    ERROR - (554, b'Transaction failed: Unsupported encoding us_ascii.')
    这是类的 __init__ 中的默认值方法,这是无效的:
    https://github.com/apache/airflow/blob/1.10.10/airflow/operators/email_operator.py#L63
    您可以通过传入有效值来修复它,例如“utf-8”:
    email_status = EmailOperator(
    mime_charset='utf-8',
    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
    )

    关于python - Airflow - 使用 AWS SES 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62660347/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com