PyMenuSite/mail.py

27 lines
794 B
Python
Raw Normal View History

2023-02-11 10:06:36 -05:00
import ssl
import smtplib
2023-02-12 06:29:18 -05:00
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
2023-02-11 10:06:36 -05:00
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):
2023-02-12 06:29:18 -05:00
email = MIMEMultipart()
2023-02-11 10:06:36 -05:00
email['From'] = config["display_name"]
email["To"] = mail_add;
email["subject"] = subject;
2023-02-12 06:29:18 -05:00
email.attach(MIMEText(mail_content, "html"))
2023-02-11 10:06:36 -05:00
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());