Add 'from_name' field to SMTP settings and update email sending logic #7

Merged
smueller merged 1 commits from dev into main 2026-07-07 14:00:40 +00:00
3 changed files with 11 additions and 1 deletions
Showing only changes of commit f2cfe8de3e - Show all commits

View File

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

View File

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

View File

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