main #14

Merged
smueller merged 13 commits from main into dev 2026-07-09 08:59:59 +00:00
3 changed files with 11 additions and 1 deletions
Showing only changes of commit 42cef23957 - Show all commits

View File

@@ -482,6 +482,7 @@ def update_smtp_settings(
username: str = Form(""), username: str = Form(""),
password: str = Form(""), password: str = Form(""),
from_email: str = Form(""), from_email: str = Form(""),
from_name: str = Form(""),
reply_to: str = Form(""), reply_to: str = Form(""),
use_tls: str | None = Form(None), use_tls: str | None = Form(None),
recipients: str = Form(""), recipients: str = Form(""),
@@ -504,6 +505,7 @@ def update_smtp_settings(
set_config(db, "smtp.username", username.strip()) set_config(db, "smtp.username", username.strip())
set_config(db, "smtp.password", password) set_config(db, "smtp.password", password)
set_config(db, "smtp.from_email", from_email.strip()) set_config(db, "smtp.from_email", from_email.strip())
set_config(db, "smtp.from_name", from_name.strip())
set_config(db, "smtp.reply_to", reply_to.strip()) set_config(db, "smtp.reply_to", reply_to.strip())
set_config(db, "smtp.use_tls", "true" if use_tls == "true" else "false") set_config(db, "smtp.use_tls", "true" if use_tls == "true" else "false")
set_config(db, "smtp.recipients", recipients.strip()) set_config(db, "smtp.recipients", recipients.strip())

View File

@@ -2,6 +2,7 @@ import smtplib
from datetime import datetime from datetime import datetime
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText from email.mime.text import MIMEText
from email.utils import formataddr
from typing import Sequence from typing import Sequence
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
@@ -18,6 +19,7 @@ def get_smtp_settings(db: Session) -> dict[str, str]:
"username": get_config(db, "smtp.username", ""), "username": get_config(db, "smtp.username", ""),
"password": get_config(db, "smtp.password", ""), "password": get_config(db, "smtp.password", ""),
"from_email": get_config(db, "smtp.from_email", ""), "from_email": get_config(db, "smtp.from_email", ""),
"from_name": get_config(db, "smtp.from_name", ""),
"reply_to": get_config(db, "smtp.reply_to", ""), "reply_to": get_config(db, "smtp.reply_to", ""),
"use_tls": get_config(db, "smtp.use_tls", "true"), "use_tls": get_config(db, "smtp.use_tls", "true"),
"recipients": get_config(db, "smtp.recipients", ""), "recipients": get_config(db, "smtp.recipients", ""),
@@ -90,7 +92,10 @@ def send_newsletter(
msg.attach(MIMEText(text_content, "plain", "utf-8")) msg.attach(MIMEText(text_content, "plain", "utf-8"))
msg.attach(MIMEText(html_content, "html", "utf-8")) msg.attach(MIMEText(html_content, "html", "utf-8"))
msg["Subject"] = subject msg["Subject"] = subject
msg["From"] = settings["from_email"] if settings.get("from_name"):
msg["From"] = formataddr((settings["from_name"], settings["from_email"]))
else:
msg["From"] = settings["from_email"]
msg["To"] = ", ".join(recipients) msg["To"] = ", ".join(recipients)
if settings.get("reply_to"): if settings.get("reply_to"):
msg["Reply-To"] = settings["reply_to"] msg["Reply-To"] = settings["reply_to"]

View File

@@ -253,6 +253,9 @@
<input type="password" name="password" value="{{ smtp.password }}"> <input type="password" name="password" value="{{ smtp.password }}">
</label> </label>
</div> </div>
<label>Absender-Name
<input type="text" name="from_name" value="{{ smtp.from_name }}" placeholder="Thomas-Krenn Wiki-Team">
</label>
<div class="form-row"> <div class="form-row">
<label>Absender E-Mail <label>Absender E-Mail
<input type="email" name="from_email" value="{{ smtp.from_email }}"> <input type="email" name="from_email" value="{{ smtp.from_email }}">