From 41c794d1b1bcc82570d9ceea5b9b0ec701384251 Mon Sep 17 00:00:00 2001 From: Marc Schubert Date: Wed, 20 Sep 2023 17:20:34 +0200 Subject: [PATCH 1/3] repair receiver address --- src/notify.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/notify.py b/src/notify.py index 53f9c32e4..7a6967416 100644 --- a/src/notify.py +++ b/src/notify.py @@ -36,7 +36,7 @@ def send(config, last_send=None, dry_run=False): else: smtp.login(email, password) - msg = build_message(email) + msg = build_message(email, to_email) smtp.sendmail(from_addr=email, to_addrs=to_email, msg=msg.as_string()) smtp.quit() @@ -49,9 +49,9 @@ def send(config, last_send=None, dry_run=False): return sent_on -def build_message(email): +def build_message(email, to_email): """Create email message.""" - message = Message(to=email) + message = Message(to=to_email) message.sender = "icloud-docker <" + email + ">" message.date = datetime.datetime.now().strftime("%d/%m/%Y %H:%M") message.subject = "icloud-docker: Two step authentication required" From 299eb8cf5ee0239bfae5fc89a1262900f95be73f Mon Sep 17 00:00:00 2001 From: Marc Schubert Date: Wed, 20 Sep 2023 21:31:12 +0200 Subject: [PATCH 2/3] Extend test use case --- tests/test_notify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_notify.py b/tests/test_notify.py index d9bdab455..e8c19ac39 100644 --- a/tests/test_notify.py +++ b/tests/test_notify.py @@ -44,7 +44,7 @@ def test_dry_run_send(self): def test_build_message(self): """Test for building a valid email.""" - msg = notify.build_message(self.config["app"]["smtp"]["email"]) + msg = notify.build_message(self.config["app"]["smtp"]["email"], self.config["app"]["smtp"]["email"]) self.assertEqual(msg.to, self.config["app"]["smtp"]["email"]) self.assertIn(self.config["app"]["smtp"]["email"], msg.sender) self.assertIn("icloud-docker: Two step authentication required", msg.subject) From 3de135fe1290d215141ab3a814c1f07dd9699e2e Mon Sep 17 00:00:00 2001 From: Mandar Patil Date: Thu, 21 Sep 2023 14:52:46 +0000 Subject: [PATCH 3/3] updates to tests; --- tests/test_notify.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_notify.py b/tests/test_notify.py index e8c19ac39..8ceee2daf 100644 --- a/tests/test_notify.py +++ b/tests/test_notify.py @@ -16,6 +16,7 @@ def setUp(self) -> None: "app": { "smtp": { "email": "user@test.com", + "to": "to@email.com", "host": "smtp.test.com", "port": "587", "password": "password", @@ -44,8 +45,11 @@ def test_dry_run_send(self): def test_build_message(self): """Test for building a valid email.""" - msg = notify.build_message(self.config["app"]["smtp"]["email"], self.config["app"]["smtp"]["email"]) - self.assertEqual(msg.to, self.config["app"]["smtp"]["email"]) + msg = notify.build_message( + email=self.config["app"]["smtp"]["email"], + to_email=self.config["app"]["smtp"]["to"], + ) + self.assertEqual(msg.to, self.config["app"]["smtp"]["to"]) self.assertIn(self.config["app"]["smtp"]["email"], msg.sender) self.assertIn("icloud-docker: Two step authentication required", msg.subject) self.assertIn(