From 027b3512e1c7493fd3aeb28c2518ee5c15eac30a Mon Sep 17 00:00:00 2001
From: Jan Hartig <jan.hartig@ptb.de>
Date: Mon, 28 Aug 2023 11:38:47 +0000
Subject: [PATCH] Fix error mails

---
 mailservice.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/mailservice.py b/mailservice.py
index 1750989..bb46296 100644
--- a/mailservice.py
+++ b/mailservice.py
@@ -92,16 +92,19 @@ def main(end):
                     msg = EmailMessage()
                     msg["Subject"] = "Subtitle Service Error Report"
                     msg["From"] = config["MAIL"]["FROM"]
-                    msg["To"] = config["MONITORING"]["MAIL"]
+                    msg["To"] = config["MONITORING_MAIL"]
 
                     job_uuids = []
                     for job in error_jobs:
                         job_uuids.append(Path(job).name)
 
                     msg.set_content(
-                        "The following jobs currently have errors:\n{}".format("\n - ".join(job_uuids))
+                        "The following jobs currently have errors:\n\n - {}".format("\n - ".join(job_uuids))
                     )
 
+                    s.send_message(msg)
+                    sent += 1
+
                 except KeyError:
                     pass
 
@@ -122,7 +125,7 @@ def main(end):
             pass
 
         print(
-            "[MAILSERVICE] Sent {} mails. Sleeping for {} seconds.".format(
+            "[MAILSERVICE] Sent {} mail(s). Sleeping for {} seconds.".format(
                 sent, config["MAILSERVICE_INTERVAL"]
             )
         )
-- 
GitLab