diff --git a/spark_expectations/notifications/plugins/email.py b/spark_expectations/notifications/plugins/email.py index 32776592..a126e54e 100644 --- a/spark_expectations/notifications/plugins/email.py +++ b/spark_expectations/notifications/plugins/email.py @@ -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") diff --git a/tests/notification/plugins/test_email.py b/tests/notification/plugins/test_email.py index 430db1dc..be985d85 100644 --- a/tests/notification/plugins/test_email.py +++ b/tests/notification/plugins/test_email.py @@ -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 = "sender@example.com" - _mock_context.get_to_mail = "receiver@example.com" + _mock_context.get_to_mail = "receiver1@example.com, 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 @@ -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()