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