From 446fa0c049b3be0a0c6906c5f533535c39570449 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Mon, 9 Dec 2024 14:27:04 -0800 Subject: [PATCH] timeout --- modules/smtp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/smtp.py b/modules/smtp.py index 7fead13..beac799 100644 --- a/modules/smtp.py +++ b/modules/smtp.py @@ -13,6 +13,7 @@ # System variables trap_list_smtp = ("email:", "setemail:", "sms:", "setsms:", "clearsms:") smtpThrottle = {} +SMTP_TIMEOUT = 10 if enableImap: # Import IMAP library @@ -44,7 +45,7 @@ def send_email(to_email, message, nodeID=0): msg.attach(MIMEText(message, 'plain')) # Connect to SMTP server - server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT) + server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT, timeout=SMTP_TIMEOUT) server.starttls() server.login(SMTP_USERNAME, SMTP_PASSWORD) @@ -64,7 +65,7 @@ def check_email(nodeID, sysop=False): try: # Connect to IMAP server - mail = imaplib.IMAP4_SSL(IMAP_SERVER) + mail = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT, timeout=SMTP_TIMEOUT) mail.login(IMAP_USERNAME, IMAP_PASSWORD) mail.select(IMAP_FOLDER)