From 749782b15b7cc7721a0a57e44ca8dd4f016ccacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20M=C3=BCtsch?= Date: Mon, 23 Jan 2023 16:23:18 +0100 Subject: [PATCH] chore: error handling in mailing script [skip ci] --- scripts/send_mail.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/send_mail.py b/scripts/send_mail.py index 317a978..6db7b27 100644 --- a/scripts/send_mail.py +++ b/scripts/send_mail.py @@ -1,4 +1,5 @@ import argparse +import logging import time import requests @@ -36,8 +37,11 @@ def send(recipient: str, subject: str, content: str, is_html: bool = False, base def run(args): content, is_html = read_mail_content(args.content) for recipient in tqdm(read_recipients(args.recipients)): - send(recipient, args.subject, content, is_html, args.mw_url) - time.sleep(args.throttle) + try: + send(recipient, args.subject, content, is_html, args.mw_url) + time.sleep(args.throttle) + except Exception as e: + logging.warning(f'failed to send to {recipient}, {e}') def parse_arguments():