Compare commits
2 Commits
32f10c3197
...
42cef23957
| Author | SHA1 | Date | |
|---|---|---|---|
| 42cef23957 | |||
|
|
f2cfe8de3e |
@@ -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())
|
||||||
|
|||||||
@@ -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,6 +92,9 @@ 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
|
||||||
|
if settings.get("from_name"):
|
||||||
|
msg["From"] = formataddr((settings["from_name"], settings["from_email"]))
|
||||||
|
else:
|
||||||
msg["From"] = settings["from_email"]
|
msg["From"] = settings["from_email"]
|
||||||
msg["To"] = ", ".join(recipients)
|
msg["To"] = ", ".join(recipients)
|
||||||
if settings.get("reply_to"):
|
if settings.get("reply_to"):
|
||||||
|
|||||||
@@ -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 }}">
|
||||||
|
|||||||
Reference in New Issue
Block a user