removed empty entries in to_emails

removed empty entries in `to_emails` caused i.e. by the input `,` as pointed out in https://github.com/netalertx/NetAlertX/pull/1732#discussion_r3738840647 
Also added an abort if no entries remain in `to_emails` after this step.
This commit is contained in:
etgocode authored and GitHub committed 2026-08-08 00:54:44 +02:00
1 parent 72a0b091ce
commit 69de0dd86f
1 file changed
+8
@@ -118,6 +118,14 @@ def send(pHTML, pText):
to_emails = get_setting_value("SMTP_REPORT_TO").split(',')
else:
to_emails.append(get_setting_value("SMTP_REPORT_TO"))
# remove empty array entries
to_emails = [x for x in to_emails if x]
# throw error if array empty
if not to_emails:
mylog('none', [f'[Email Check Config] ⚠ ERROR: Email service not set up correctly. Check your {confFileName} SMTP_REPORT_TO variable.'])
return False
subject, from_email, emails, message_html, message_text = sanitize_email_content(
str(get_setting_value("SMTP_SUBJECT")),