chore: error handling in mailing script [skip ci]

This commit is contained in:
Ferdinand Mütsch 2023-01-23 16:23:18 +01:00
parent c42985a279
commit 749782b15b
1 changed files with 6 additions and 2 deletions

View File

@ -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():