【发布时间】:2023-02-18 05:24:10
【问题描述】:
我正在尝试使用发送电子邮件发送网格但 DAG 一直在运行。 我做了以下事情:
- 设置环境变量SENDGRID_MAIL_FROM作为我的电子邮件
- 设置环境变量SENDGRID_API_KEY作为我在确认我的个人电子邮件(与发件人电子邮件相同)后从 Sendgrid 生成的 api。
我的电子邮件收件箱中没有垃圾邮件。 SendGrid 页面上的“活动”部分未找到任何内容,也未发送任何内容。 有人可以指出我做错了什么吗?
我的代码:
from airflow.models import (DAG, Variable) import os from airflow.operators.email import EmailOperator from datetime import datetime,timedelta default_args = { 'start_date': datetime(2020, 1, 1), 'owner': 'Airflow', "email_on_failure" : False, "email_on_retry" : False, "emails" : ['my@myemail.com'] } PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "bigquery_default") PROJECT_ID_GCP = os.environ.get("GCP_PROJECT_ID", "my_progect") with DAG( 'retries_test', schedule_interval=None, catchup=False, default_args=default_args ) as dag: send_email_notification = EmailOperator( task_id = "send_email_notification", to = "test@sendgrid.com", subject = "test", html_content = "<h3>Hello</h3>" ) send_email_notification
【问题讨论】:
-
你有什么解决办法吗?我面临同样的问题。
-
很不幸的是,不行。
-
实际上我让它工作了,但是使用了 PythonOperator 和
from airflow.utils.email import send_email方法。
标签: google-cloud-platform airflow sendgrid google-cloud-composer