PyMenuSite/mail.py
2023-02-12 12:29:18 +01:00

27 lines
794 B
Python

import ssl
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
config = {
"server": "ssl0.ovh.net",
"port": 465,
"email": "auto@chauvet.pro",
"password": "#FL7Sf*9hZMkund24$a@46ny7Dx",
"display_name": "no-reply@chauvet.pro"
}
def send_mail(mail_add:str, subject:str, mail_content:str):
email = MIMEMultipart()
email['From'] = config["display_name"]
email["To"] = mail_add;
email["subject"] = subject;
email.attach(MIMEText(mail_content, "html"))
context = ssl.create_default_context();
with smtplib.SMTP_SSL(config["server"], config["port"], context=context) as smtp:
smtp.login(config["email"], config["password"]);
smtp.sendmail(config["email"], mail_add, email.as_string());