fix: v0.5.5 - SMTP auf EmailMessage + async SMTP-Client umgestellt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ppfeiffer 2026-02-17 15:54:40 +01:00
parent b1fa21504b
commit 5b2a5867d5
3 changed files with 21 additions and 12 deletions

View file

@ -1,5 +1,11 @@
# Changelog
## [0.5.5] - 2026-02-17
### Changed
- SMTP-Versand auf EmailMessage + aiosmtplib.SMTP (async context manager) umgestellt
- Plaintext-Fallback fuer nicht-HTML-faehige E-Mail-Clients
- SMTP-Host zurueck auf ssl0.ovh.net
## [0.5.4] - 2026-02-16
### Added
- Admin: Benutzer direkt anlegen mit Passwort und Rollenwahl

View file

@ -1,4 +1,4 @@
version: "0.5.4"
version: "0.5.5"
bot:
name: "MeshDD-Bot"

View file

@ -96,26 +96,29 @@ async def _send_email(db, recipient: str, subject: str, html_body: str):
try:
import aiosmtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.message import EmailMessage
msg = MIMEMultipart("alternative")
msg = EmailMessage()
msg["Subject"] = subject
msg["From"] = config.env("SMTP_FROM", "MeshDD-Bot <noreply@example.com>")
msg["To"] = recipient
msg.attach(MIMEText(html_body, "html"))
msg.set_content("Bitte HTML-fähigen E-Mail-Client verwenden.")
msg.add_alternative(html_body, subtype="html")
smtp_port = int(config.env("SMTP_PORT", "465"))
use_tls = smtp_port == 465
await aiosmtplib.send(
msg,
smtp_client = aiosmtplib.SMTP(
hostname=smtp_host,
port=smtp_port,
username=config.env("SMTP_USER"),
password=config.env("SMTP_PASSWORD"),
use_tls=use_tls,
start_tls=not use_tls,
use_tls=True,
)
async with smtp_client:
await smtp_client.login(
config.env("SMTP_USER"),
config.env("SMTP_PASSWORD"),
)
await smtp_client.send_message(msg)
await db.log_email(recipient, subject, "sent")
logger.info("Email sent to %s: %s", recipient, subject)
except Exception as e: