usermod/Utils/EmailUtils.py

18 lines
534 B
Python
Raw Normal View History

2023-02-07 08:48:41 +08:00
import json
import requests
from Context.common import ctx
def send_email(title: str, email: str, msg_body: str):
email_api = ctx.common_conf['email']['api']
sender = ctx.common_conf['email']['sender']
headers = {"Content-Type": "application/json;charset=UTF-8"}
data = {
"title": title,
"sender": sender,
"recipients": [email],
"msg_body": msg_body
}
res = requests.post(url=email_api + '/send_mail', headers=headers, data=json.dumps(data))
return res.status_code == 200