overleaf/user_tools/send_mail.py
2024-04-09 20:09:22 +02:00

21 lines
432 B
Python

import smtplib
from email.message import EmailMessage
def send_mail(
email_body: str,
email_subject: str,
email_from: str,
email_to: str,
smtpd_host: str = "overleafsmtpd",
):
msg = EmailMessage()
msg.set_content(email_body.decode("utf-8"))
msg["Subject"] = email_subject
msg["From"] = email_from
msg["To"] = email_to
s = smtplib.SMTP(smtpd_host)
s.send_message(msg)
s.quit()