From 7ab60ea9c99392b6915279122a1aab1ad2a10035 Mon Sep 17 00:00:00 2001 From: "Heindl, Lukas" <191340695+Lukas-Heindl@users.noreply.github.com> Date: Thu, 24 Apr 2025 12:48:35 +0200 Subject: [PATCH] related to #2586 Sending mails with the smtp_batch output might fail e.g. due to wrong settings regarding the SMTP-Server. So far this is not reflected in the exit code when running the bot via cli to trigger sending the mails. Fixing this (at least for the non-interactive call) enables users to integrate this into their monitoring properly. --- intelmq/bots/outputs/smtp_batch/output.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/intelmq/bots/outputs/smtp_batch/output.py b/intelmq/bots/outputs/smtp_batch/output.py index 5661ea7339..b5aa5f0997 100644 --- a/intelmq/bots/outputs/smtp_batch/output.py +++ b/intelmq/bots/outputs/smtp_batch/output.py @@ -167,8 +167,12 @@ def cli_run(self): sys.exit(0) elif i == "all": count = 0 + exit_code = 0 for mail in mails: - if self.build_mail(mail, send=True): + succ = self.build_mail(mail, send=True) + if not succ: + exit_code = 1 + else: count += 1 print(f"{mail.to} ", end="", flush=True) try: @@ -183,7 +187,7 @@ def cli_run(self): if mail.path: os.unlink(mail.path) print(f"\n{count}× mail sent.\n") - sys.exit(0) + sys.exit(exit_code) elif i == "clear": for mail in mails: self.cache.redis.delete(mail.key)