Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiple email recipients #113

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: 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
Loading