Files
infra/14_infra-assistant/api/notifications/mailer.py
T

16 lines
460 B
Python
Raw Normal View History

2026-03-21 14:12:55 +01:00
import smtplib
from email.message import EmailMessage
import os
def send_mail(body: str):
msg = EmailMessage()
msg["Subject"] = "Alerte Infrastructure"
msg["From"] = os.getenv("SMTP_USER")
msg["To"] = os.getenv("MAIL_TO")
msg.set_content(body)
with smtplib.SMTP(os.getenv("SMTP_HOST"), int(os.getenv("SMTP_PORT"))) as s:
s.starttls()
s.login(os.getenv("SMTP_USER"), os.getenv("SMTP_PASS"))
s.send_message(msg)