Skip to content

Commit 7ab60ea

Browse files
Lukas-Heindlsebix
authored andcommitted
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.
1 parent 806d81e commit 7ab60ea

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

intelmq/bots/outputs/smtp_batch/output.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,12 @@ def cli_run(self):
167167
sys.exit(0)
168168
elif i == "all":
169169
count = 0
170+
exit_code = 0
170171
for mail in mails:
171-
if self.build_mail(mail, send=True):
172+
succ = self.build_mail(mail, send=True)
173+
if not succ:
174+
exit_code = 1
175+
else:
172176
count += 1
173177
print(f"{mail.to} ", end="", flush=True)
174178
try:
@@ -183,7 +187,7 @@ def cli_run(self):
183187
if mail.path:
184188
os.unlink(mail.path)
185189
print(f"\n{count}× mail sent.\n")
186-
sys.exit(0)
190+
sys.exit(exit_code)
187191
elif i == "clear":
188192
for mail in mails:
189193
self.cache.redis.delete(mail.key)

0 commit comments

Comments
 (0)