mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 05:25:26 +02:00
fix: Add SMTP Timeout (#4437)
This commit is contained in:
parent
34bd4a74c2
commit
2305438423
1 changed files with 5 additions and 2 deletions
|
@ -10,6 +10,9 @@ from html2text import html2text
|
|||
|
||||
from mealie.services._base_service import BaseService
|
||||
|
||||
SMTP_TIMEOUT = 10
|
||||
"""Timeout in seconds for SMTP connection"""
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class EmailOptions:
|
||||
|
@ -55,13 +58,13 @@ class Message:
|
|||
msg["MIME-Version"] = "1.0"
|
||||
|
||||
if smtp.ssl:
|
||||
with smtplib.SMTP_SSL(smtp.host, smtp.port) as server:
|
||||
with smtplib.SMTP_SSL(smtp.host, smtp.port, timeout=SMTP_TIMEOUT) as server:
|
||||
if smtp.username and smtp.password:
|
||||
server.login(smtp.username, smtp.password)
|
||||
|
||||
errors = server.send_message(msg)
|
||||
else:
|
||||
with smtplib.SMTP(smtp.host, smtp.port) as server:
|
||||
with smtplib.SMTP(smtp.host, smtp.port, timeout=SMTP_TIMEOUT) as server:
|
||||
if smtp.tls:
|
||||
server.starttls()
|
||||
if smtp.username and smtp.password:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue