一 . 配置文件
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, }
三 . 效果