I\'m trying to make an Airflow task intentionally fail and error out by passing in a Bash line (thisshouldnotrun
) that doesn\'t work. Airflow is outputting the
Use below link for creating airflow dag.
How to trigger daily DAG run at midnight local time instead of midnight UTC time
Approach 1 : You can setup SMTP locally and make it send email on jobs failure.
[email]
email_backend = airflow.utils.email.send_email_smtp
[smtp]
smtp_host = localhost
smtp_starttls = False
smtp_ssl = False
smtp_port = 25
smtp_mail_from = noreply@company.com
Approach 2 : You can use Gmail to send email. I have written an article to do this. https://helptechcommunity.wordpress.com/2020/04/04/airflow-email-configuration/
smtp_starttls
basically means Use TLS
Set this to False
and set smtp_ssl
to True
if you want to use SSL instead. You probably need smtp_user
and smtp_password
for either.
Airflow will not handle 2 step authentication. However, is you are using AWS you likely don't need it as your SMTP (SES) credentials are different from your AWS credentials.
See here.
EDIT:
For airflow to send an email on failure, there are a couple things that need to be set on your task, email_on_failure
and email
.
See here for example:
def throw_error(**context):
raise ValueError('Intentionally throwing an error to send an email.')
t1 = PythonOperator(task_id='throw_error_and_email',
python_callable=throw_error,
provide_context=True,
email_on_failure=True,
email='your.email@whatever.com',
dag=dag)