gallery.accords-library.com/server/szurubooru/func/mailer.py

23 lines
583 B
Python
Raw Normal View History

2016-04-03 20:03:58 +00:00
import email.mime.text
import smtplib
2016-04-03 20:03:58 +00:00
from szurubooru import config
def send_mail(sender: str, recipient: str, subject: str, body: str) -> None:
2016-04-03 20:03:58 +00:00
msg = email.mime.text.MIMEText(body)
msg["Subject"] = subject
msg["From"] = sender
msg["To"] = recipient
2016-04-03 20:03:58 +00:00
smtp = smtplib.SMTP(
config.config["smtp"]["host"], int(config.config["smtp"]["port"])
)
try:
smtp.starttls()
except smtplib.SMTPNotSupportedError:
pass
smtp.login(config.config["smtp"]["user"], config.config["smtp"]["pass"])
2016-04-03 20:03:58 +00:00
smtp.send_message(msg)
smtp.quit()