Skip to content

Commit

Permalink
Pass custom headers through in SES email backend (#22667)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: de84eaf1b042304dd966219da22c7c529afbb662
  • Loading branch information
repl-mike-roest authored and Cloud Composer Team committed Sep 12, 2024
1 parent 3c0b0b2 commit 2795015
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion airflow/providers/amazon/aws/utils/emailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# specific language governing permissions and limitations
# under the License.
"""Airflow module for email backend using AWS SES"""
from typing import List, Optional, Union
from typing import Any, Dict, List, Optional, Union

from airflow.providers.amazon.aws.hooks.ses import SesHook

Expand All @@ -32,6 +32,7 @@ def send_email(
mime_charset: str = 'utf-8',
conn_id: str = 'aws_default',
from_email: Optional[str] = None,
custom_headers: Optional[Dict[str, Any]] = None,
**kwargs,
) -> None:
"""Email backend for SES."""
Expand All @@ -48,4 +49,5 @@ def send_email(
bcc=bcc,
mime_subtype=mime_subtype,
mime_charset=mime_charset,
custom_headers=custom_headers,
)
2 changes: 2 additions & 0 deletions tests/providers/amazon/aws/utils/test_emailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_send_ses_email(self, mock_hook):
subject="subject",
html_content="content",
from_email="From Test <from@test.com>",
custom_headers={"X-Test-Header": "test-val"},
)

mock_hook.return_value.send_email.assert_called_once_with(
Expand All @@ -43,6 +44,7 @@ def test_send_ses_email(self, mock_hook):
files=None,
mime_charset="utf-8",
mime_subtype="mixed",
custom_headers={"X-Test-Header": "test-val"},
)

@mock.patch("airflow.providers.amazon.aws.utils.emailer.SesHook")
Expand Down

0 comments on commit 2795015

Please sign in to comment.