04/24 Added import website in bulk

This commit is contained in:
2026-04-24 13:57:49 -04:00
parent 5f2a4e4749
commit 88b5e85c5b
7 changed files with 567 additions and 33 deletions
+31 -7
View File
@@ -27,6 +27,7 @@ import smtplib
import threading
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import formatdate, make_msgid, formataddr
logger = logging.getLogger("scheduler")
@@ -213,10 +214,21 @@ def send_test_email(smtp_host: str, smtp_port: int,
"<p>You can now enable daily reports from the Email Settings panel.</p>"
"</body></html>"
)
plain = (
"Website Checker — SMTP Test\n\n"
"This is a test email confirming your SMTP configuration is working.\n"
"You can now enable daily reports from the Email Settings panel."
)
msg = MIMEMultipart("alternative")
msg["Subject"] = subject
msg["From"] = smtp_user
msg["To"] = ", ".join(recipients)
msg["Subject"] = subject
msg["From"] = formataddr(("Website Checker", smtp_user))
msg["To"] = ", ".join(recipients)
msg["Date"] = formatdate(localtime=True)
msg["Message-ID"] = make_msgid(domain=smtp_user.split("@")[-1] if "@" in smtp_user else "webchecker")
msg["X-Mailer"] = "WebChecker"
# Plain-text part must come first; HTML second.
# Spam filters heavily penalise HTML-only messages with no text/plain alternative.
msg.attach(MIMEText(plain, "plain", "utf-8"))
msg.attach(MIMEText(body, "html", "utf-8"))
server = _make_smtp_server(smtp_host, smtp_port, security)
@@ -316,10 +328,22 @@ def _send_report(cfg: dict):
today = datetime.date.today().strftime("%d %b %Y")
subject = f"Website Checker — Daily Report {today}"
smtp_user = cfg["smtp_user"]
plain = (
f"Website Checker — Daily Report {today}\n\n"
"Please view this report in an HTML-capable email client for full formatting.\n"
"This email was sent automatically by Website Checker."
)
msg = MIMEMultipart("alternative")
msg["Subject"] = subject
msg["From"] = cfg["smtp_user"]
msg["To"] = ", ".join(cfg["recipients"])
msg["Subject"] = subject
msg["From"] = formataddr(("Website Checker", smtp_user))
msg["To"] = ", ".join(cfg["recipients"])
msg["Date"] = formatdate(localtime=True)
msg["Message-ID"] = make_msgid(domain=smtp_user.split("@")[-1] if "@" in smtp_user else "webchecker")
msg["X-Mailer"] = "WebChecker"
# Plain-text part must come first; HTML second.
# Spam filters heavily penalise HTML-only messages with no text/plain alternative.
msg.attach(MIMEText(plain, "plain", "utf-8"))
msg.attach(MIMEText(html, "html", "utf-8"))
try:
@@ -424,4 +448,4 @@ def stop():
"""Signal the scheduler to stop cleanly."""
global _stop_event
_stop_event.set()
logger.info("Email scheduler stopped.")
logger.info("Email scheduler stopped.")