Add support for "from_name" field in email notifications
All checks were successful
PostgreSQL Compatibility Matrix / PG14 smoke (push) Successful in 7s
PostgreSQL Compatibility Matrix / PG15 smoke (push) Successful in 7s
PostgreSQL Compatibility Matrix / PG16 smoke (push) Successful in 7s
PostgreSQL Compatibility Matrix / PG17 smoke (push) Successful in 6s
PostgreSQL Compatibility Matrix / PG18 smoke (push) Successful in 6s

Introduced a new optional "from_name" attribute to email settings, allowing customization of the sender's display name in outgoing emails. Updated backend models, APIs, and front-end components to include and handle this field properly. This enhances email clarity and personalization for users.
This commit is contained in:
2026-02-12 15:31:03 +01:00
parent ea26ef4d33
commit 648ff07651
8 changed files with 177 additions and 61 deletions

View File

@@ -3,6 +3,7 @@ from __future__ import annotations
import asyncio
from datetime import datetime, timedelta, timezone
from email.message import EmailMessage
from email.utils import formataddr
import smtplib
import ssl
@@ -21,6 +22,7 @@ async def _smtp_send(
port: int,
username: str | None,
password: str | None,
from_name: str | None,
from_email: str,
recipient: str,
subject: str,
@@ -30,7 +32,7 @@ async def _smtp_send(
) -> None:
def _send() -> None:
message = EmailMessage()
message["From"] = from_email
message["From"] = formataddr((from_name, from_email)) if from_name else from_email
message["To"] = recipient
message["Subject"] = subject
message.set_content(body)
@@ -132,6 +134,7 @@ async def process_target_owner_notifications(db: AsyncSession, status: AlertStat
port=settings.smtp_port,
username=settings.smtp_username,
password=password,
from_name=settings.from_name,
from_email=settings.from_email,
recipient=recipient,
subject=subject,