rate-sys-template/Utils/EmailUtils.py

25 lines
650 B
Python

import json
import requests
import re
def email_check(email: str):
"""
邮箱验证
"""
reg = "^[a-zA-Z0-9_-]+@fecr.com.cn$"
return re.match(reg, email)
def send_email(title: str, email: str, msg_body: str, email_api="http://116.63.130.34:30001",
sender="fecribd@fecr.com.cn"):
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), timeout=5)
return res.status_code == 200