Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions airflow/providers/smtp/operators/smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ class EmailOperator(BaseOperator):
:param html_content: content of the email, html markup
is allowed. (templated)
:param files: file names to attach in email (templated)
:param cc: list of recipients to be added in CC field
:param bcc: list of recipients to be added in BCC field
:param cc: list of recipients to be added in CC field (templated)
:param bcc: list of recipients to be added in BCC field (templated)
:param mime_subtype: MIME sub content type
:param mime_charset: character set parameter added to the Content-Type
header.
:param custom_headers: additional headers to add to the MIME message.
"""

template_fields: Sequence[str] = ("to", "from_email", "subject", "html_content", "files")
template_fields: Sequence[str] = ("to", "from_email", "subject", "html_content", "files", "cc", "bcc")
template_fields_renderers = {"html_content": "html"}
template_ext: Sequence[str] = (".html",)
ui_color = "#e6faf9"
Expand Down
11 changes: 10 additions & 1 deletion tests/providers/smtp/operators/test_smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@


class TestEmailOperator:
def setup_method(self):
self.default_op_kwargs = dict(to="to", subject="subject", html_content="content")

@patch("airflow.providers.smtp.hooks.smtp.SmtpHook.get_connection")
@patch(smtplib_string)
def test_loading_sender_email_from_connection(self, mock_smtplib, mock_hook_conn):
Expand All @@ -46,7 +49,13 @@ def test_loading_sender_email_from_connection(self, mock_smtplib, mock_hook_conn
),
)
smtp_client_mock = mock_smtplib.SMTP_SSL()
op = EmailOperator(task_id="test_email", to="to", subject="subject", html_content="content")
op = EmailOperator(task_id="test_email", **self.default_op_kwargs)
op.execute({})
call_args = smtp_client_mock.sendmail.call_args.kwargs
assert call_args["from_addr"] == sender_email

def test_assert_templated_fields(self):
"""Test expected templated fields."""
operator = EmailOperator(task_id="test_assert_templated_fields", **self.default_op_kwargs)
template_fields = ("to", "from_email", "subject", "html_content", "files", "cc", "bcc")
assert operator.template_fields == template_fields