一 . 配置文件
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 = smtp.smtp.smtp.com smtp_starttls = False smtp_ssl = True # Uncomment and set the user/pass settings if you want to use SMTP AUTH smtp_user = 邮箱名 smtp_password = smtp_password smtp_port = 465 smtp_mail_from = 发件人
smtp_starttls
基本上意味着使用TLS
如果要改用SSL,请将此设置设置为False
,并将smtp_ssl
设置为True
。您可能需要smtp_user
和smtp_password
两种方法
因为我邮箱在服务器上开通的是SSL传输,所以打开了 smtp_ssl
二 . 脚本中配置
args = { 'owner': 'airflow', 'start_date': start_date, 'email': ['email@163.com'], 'email_on_failure': True, #失败之后再次发送 'email_on_retry': True, 'depends_on_past': True, }