0

I am sending mail using airflow emailOperator. Is there any way to send "reply-to" parameter also. i tried default_param={'key':'value'} but throwing exception as invalid parameter. I read this https://github.com/apache/airflow/blob/main/airflow/operators/email.py https://github.com/apache/airflow/blob/main/tests/operators/test_email.py But I don't know where i am doing mistake. version : 2.0.2

email_op = EmailOperator(
            task_id='send_email',
            to=destination['emails'],
            subject=destination['subject'],
            html_content=destination['message'],
            files=[file.name],
            default_param={'Reply-To': 'reply_to@example.com'},
        )
 email_op.execute(context)

1 Answers1

1

It would be passed via dictionary custom_headers, as per the Official Source Code and Official Docs

I actually took the Reply-To directly from the official Airflow unit test.

There was a bug patched in release 2.3.0 with the send_email function to correctly pass the custom_headers. This might be your root cause...

For new comers here is how you would send the custom_headers when using 2.3.0 and above.

from airflow.operators.email_operator import EmailOperator

t1 = EmailOperator(
    task_id='send_email',
    to="email@example.com",
    subject="Airflow Example",
    html_content=""" <h3>Email Test</h3> """,
    cc="email@example",
    custom_headers = {
        'Reply-To': 'reply_to@example.com'
    }
)
dimButTries
  • 661
  • 7
  • 15