Skip to content

Commit

Permalink
support multiple email recipients (#113)
Browse files Browse the repository at this point in the history
* support multiple email recipients

* support multiple email recipients

---------

Co-authored-by: Kumar Abhishek <[email protected]>
  • Loading branch information
kumarabhishekpandey and Kumar Abhishek authored Nov 8, 2024
1 parent d7db1bb commit f467a78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion spark_expectations/notifications/plugins/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ def send_notification(
)
server.starttls()
text = msg.as_string()
server.sendmail(_context.get_mail_from, _context.get_to_mail, text)
server.sendmail(
_context.get_mail_from,
[email.strip() for email in _context.get_to_mail.split(",")],
text,
)
server.quit()

_log.info("email send successfully")
Expand Down
4 changes: 2 additions & 2 deletions tests/notification/plugins/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_send_notification_success(_mock_context):
email_handler = SparkExpectationsEmailPluginImpl()
_mock_context.get_enable_mail = True
_mock_context.get_mail_from = "[email protected]"
_mock_context.get_to_mail = "receiver@example.com"
_mock_context.get_to_mail = "[email protected], receiver2@example.com"
_mock_context.get_mail_subject = "Test Email"
_mock_context.get_mail_smtp_server = "mailhost.example.com"
_mock_context.get_mail_smtp_port = 587
Expand All @@ -27,7 +27,7 @@ def test_send_notification_success(_mock_context):
# assert
mock_smtp.assert_called_with(_mock_context.get_mail_smtp_server, _mock_context.get_mail_smtp_port)
mock_smtp().starttls.assert_called()
mock_smtp().sendmail.assert_called_with(_mock_context.get_mail_from, _mock_context.get_to_mail,
mock_smtp().sendmail.assert_called_with(_mock_context.get_mail_from, [email.strip() for email in _mock_context.get_to_mail.split(",")],
_mock_mltp().as_string())
mock_smtp().quit.assert_called()

Expand Down

0 comments on commit f467a78

Please sign in to comment.