0
0
Apache Airflowdevops~20 mins

EmailOperator for notifications in Apache Airflow - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
EmailOperator Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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={})
AReturns the string 'Email sent successfully' without sending email
BRaises a TypeError because 'dag' parameter is None
CSends an email to user@example.com with subject 'Test Email' and returns None
DRaises an AirflowException due to missing SMTP configuration
Attempts:
2 left
💡 Hint
EmailOperator's execute method sends the email and returns None on success.
🧠 Conceptual
intermediate
1:00remaining
Which parameter in EmailOperator specifies the email recipient?
In Airflow's EmailOperator, which parameter is used to specify the recipient email address?
Ato
Brecipient
Cemail_to
Daddress
Attempts:
2 left
💡 Hint
Think about the common English word used for sending emails.
Troubleshoot
advanced
2: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={})
AMissing 'to' parameter in EmailOperator
BIncorrect SMTP server credentials configured in Airflow settings
CThe 'html_content' parameter is empty
DThe DAG is not scheduled properly
Attempts:
2 left
💡 Hint
SMTPAuthenticationError means the email server rejected login.
🔀 Workflow
advanced
2: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?
AAdding EmailOperator as the first task in the DAG
BSetting 'trigger_rule' to 'all_success'
CUsing 'start_date' to schedule the email
DUsing the 'on_failure_callback' parameter in the task
Attempts:
2 left
💡 Hint
Callbacks run on specific task events like failure or success.
Best Practice
expert
3: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?
AStore credentials in Airflow Connections and reference them in EmailOperator
BHardcode credentials directly in the DAG file
CUse environment variables inside the DAG code without encryption
DInclude credentials in the email content for transparency
Attempts:
2 left
💡 Hint
Airflow Connections are designed to securely store credentials.