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:
parent
b1fa21504b
commit
5b2a5867d5
|
|
@ -1,5 +1,11 @@
|
||||||
# Changelog
|
# 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
|
## [0.5.4] - 2026-02-16
|
||||||
### Added
|
### Added
|
||||||
- Admin: Benutzer direkt anlegen mit Passwort und Rollenwahl
|
- Admin: Benutzer direkt anlegen mit Passwort und Rollenwahl
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
version: "0.5.4"
|
version: "0.5.5"
|
||||||
|
|
||||||
bot:
|
bot:
|
||||||
name: "MeshDD-Bot"
|
name: "MeshDD-Bot"
|
||||||
|
|
|
||||||
|
|
@ -96,26 +96,29 @@ async def _send_email(db, recipient: str, subject: str, html_body: str):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import aiosmtplib
|
import aiosmtplib
|
||||||
from email.mime.text import MIMEText
|
from email.message import EmailMessage
|
||||||
from email.mime.multipart import MIMEMultipart
|
|
||||||
|
|
||||||
msg = MIMEMultipart("alternative")
|
msg = EmailMessage()
|
||||||
msg["Subject"] = subject
|
msg["Subject"] = subject
|
||||||
msg["From"] = config.env("SMTP_FROM", "MeshDD-Bot <noreply@example.com>")
|
msg["From"] = config.env("SMTP_FROM", "MeshDD-Bot <noreply@example.com>")
|
||||||
msg["To"] = recipient
|
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"))
|
smtp_port = int(config.env("SMTP_PORT", "465"))
|
||||||
use_tls = smtp_port == 465
|
smtp_client = aiosmtplib.SMTP(
|
||||||
await aiosmtplib.send(
|
|
||||||
msg,
|
|
||||||
hostname=smtp_host,
|
hostname=smtp_host,
|
||||||
port=smtp_port,
|
port=smtp_port,
|
||||||
username=config.env("SMTP_USER"),
|
use_tls=True,
|
||||||
password=config.env("SMTP_PASSWORD"),
|
|
||||||
use_tls=use_tls,
|
|
||||||
start_tls=not use_tls,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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")
|
await db.log_email(recipient, subject, "sent")
|
||||||
logger.info("Email sent to %s: %s", recipient, subject)
|
logger.info("Email sent to %s: %s", recipient, subject)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue