Enhance newsletter functionality with contact email support
- Added support for a contact email in newsletter generation, allowing users to specify a reply-to address. - Updated the SMTP settings to include a reply-to field in the configuration. - Modified the newsletter templates to display the contact email in plain text and HTML formats. - Improved the dashboard UI to allow users to set the reply-to address when configuring SMTP settings.
This commit is contained in:
16
app/main.py
16
app/main.py
@@ -101,6 +101,7 @@ async def _run_scheduled_send_if_due() -> None:
|
||||
display=DEFAULT_DISPLAY,
|
||||
editor_tip="",
|
||||
highlight_list=[],
|
||||
contact_email=settings_snapshot.get("reply_to") or settings_snapshot.get("from_email", ""),
|
||||
)
|
||||
if gen["wiki_error"] or not gen["articles"]:
|
||||
# Kein Versand ohne Inhalt; erneuter Versuch beim nächsten Intervall.
|
||||
@@ -296,6 +297,7 @@ async def _generate_newsletter(
|
||||
display,
|
||||
editor_tip: str,
|
||||
highlight_list: list[str],
|
||||
contact_email: str = "",
|
||||
) -> dict:
|
||||
p = resolve_period(period_mode, days)
|
||||
result = {
|
||||
@@ -322,9 +324,9 @@ async def _generate_newsletter(
|
||||
"articles_new": new_articles,
|
||||
"articles_edited": edited_articles,
|
||||
"subject": create_subject(p["month_label"], p["days"]),
|
||||
"plain_text": create_plain_text(filtered, p["days"], display, category, editor_tip, highlight_list, p["label"], prange, article_type),
|
||||
"raw_html": create_html(filtered, p["days"], display, category, editor_tip, highlight_list, p["label"], prange, article_type, p["month_label"]),
|
||||
"outlook_html": create_outlook_html(filtered, p["days"], display, category, editor_tip, highlight_list, p["label"], prange, article_type, p["month_label"]),
|
||||
"plain_text": create_plain_text(filtered, p["days"], display, category, editor_tip, highlight_list, p["label"], prange, article_type, contact_email),
|
||||
"raw_html": create_html(filtered, p["days"], display, category, editor_tip, highlight_list, p["label"], prange, article_type, p["month_label"], contact_email),
|
||||
"outlook_html": create_outlook_html(filtered, p["days"], display, category, editor_tip, highlight_list, p["label"], prange, article_type, p["month_label"], contact_email),
|
||||
}
|
||||
)
|
||||
except WikiFetchError as exc:
|
||||
@@ -374,6 +376,8 @@ async def dashboard_generate(
|
||||
article_type = "all"
|
||||
display = parse_display_options(show_date, show_user, show_category)
|
||||
highlight_list = parse_highlights(highlights)
|
||||
smtp_cfg = get_smtp_settings(db)
|
||||
contact_email = smtp_cfg["reply_to"] or smtp_cfg["from_email"]
|
||||
|
||||
gen = await _generate_newsletter(
|
||||
period_mode=period,
|
||||
@@ -383,6 +387,7 @@ async def dashboard_generate(
|
||||
display=display,
|
||||
editor_tip=editor_tip,
|
||||
highlight_list=highlight_list,
|
||||
contact_email=contact_email,
|
||||
)
|
||||
|
||||
context = _base_context(request, current_user, db)
|
||||
@@ -434,6 +439,8 @@ async def send_now(
|
||||
article_type = "all"
|
||||
highlight_list = parse_highlights(highlights)
|
||||
days = max(1, min(days, 90))
|
||||
smtp_cfg = get_smtp_settings(db)
|
||||
contact_email = smtp_cfg["reply_to"] or smtp_cfg["from_email"]
|
||||
|
||||
gen = await _generate_newsletter(
|
||||
period_mode=period,
|
||||
@@ -443,6 +450,7 @@ async def send_now(
|
||||
display=display,
|
||||
editor_tip=editor_tip,
|
||||
highlight_list=highlight_list,
|
||||
contact_email=contact_email,
|
||||
)
|
||||
|
||||
send_result: dict[str, str]
|
||||
@@ -492,6 +500,7 @@ def update_smtp_settings(
|
||||
username: str = Form(""),
|
||||
password: str = Form(""),
|
||||
from_email: str = Form(""),
|
||||
reply_to: str = Form(""),
|
||||
use_tls: str | None = Form(None),
|
||||
recipients: str = Form(""),
|
||||
schedule_enabled: str | None = Form(None),
|
||||
@@ -513,6 +522,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.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())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user