Challenge - 5 Problems
EmailOperator Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Airflow EmailOperator task?
Given the following Airflow task using EmailOperator, what will be the result when the task runs successfully?
Apache Airflow
from airflow.operators.email import EmailOperator email_task = EmailOperator( task_id='send_email', to='user@example.com', subject='Test Email', html_content='<h1>Hello</h1>', dag=None ) result = email_task.execute(context={})
Attempts:
2 left
💡 Hint
EmailOperator's execute method sends the email and returns None on success.
✗ Incorrect
EmailOperator sends the email when execute() is called and returns None if successful. It does not return a string or raise error if SMTP is configured properly. 'dag=None' is allowed for standalone task testing.
🧠 Conceptual
intermediate1:00remaining
Which parameter in EmailOperator specifies the email recipient?
In Airflow's EmailOperator, which parameter is used to specify the recipient email address?
Attempts:
2 left
💡 Hint
Think about the common English word used for sending emails.
✗ Incorrect
The 'to' parameter is used to specify the recipient email address in EmailOperator.
❓ Troubleshoot
advanced2:30remaining
Why does this EmailOperator task fail with SMTPAuthenticationError?
An Airflow EmailOperator task fails with the error 'SMTPAuthenticationError: (535, b'Authentication failed')'. What is the most likely cause?
Apache Airflow
email_task = EmailOperator(
task_id='send_email',
to='user@example.com',
subject='Alert',
html_content='Task failed',
dag=dag
)
email_task.execute(context={})Attempts:
2 left
💡 Hint
SMTPAuthenticationError means the email server rejected login.
✗ Incorrect
SMTPAuthenticationError indicates the SMTP server credentials are wrong or missing in Airflow's configuration.
🔀 Workflow
advanced2:00remaining
In which Airflow DAG event is EmailOperator best used for failure notifications?
You want to send an email notification only when a DAG task fails. Which Airflow feature allows you to trigger EmailOperator only on failure?
Attempts:
2 left
💡 Hint
Callbacks run on specific task events like failure or success.
✗ Incorrect
'on_failure_callback' lets you specify a function or operator to run when a task fails, perfect for sending failure emails.
✅ Best Practice
expert3:00remaining
What is the best practice to avoid exposing email credentials in Airflow EmailOperator?
To keep email server credentials secure when using EmailOperator in Airflow, what is the recommended approach?
Attempts:
2 left
💡 Hint
Airflow Connections are designed to securely store credentials.
✗ Incorrect
Airflow Connections securely store credentials and can be referenced by operators, avoiding hardcoding sensitive data.