wd-smebiz/utils/email_utils.py

25 lines
651 B
Python
Raw Normal View History

2023-08-02 10:18:36 +08:00
import json
import requests
import re
def email_check(email: str):
"""
邮箱验证
"""
reg = "^[a-zA-Z0-9_-]+@fecr.com.cn$"
return re.match(reg, email)
2023-08-15 09:53:26 +08:00
def send_email(title: str, email: str, msg_body: str, email_api="http://116.63.130.34:30001",
2023-08-02 10:18:36 +08:00
sender="fecribd@fecr.com.cn"):
headers = {"Content-Type": "application/json;charset=UTF-8"}
data = {
"title": title,
"sender": sender,
"recipients": [email],
2023-08-02 14:24:28 +08:00
"msg_body": msg_body,
2023-08-02 10:18:36 +08:00
}
res = requests.post(url=email_api + '/send_mail', headers=headers, data=json.dumps(data), timeout=5)
return res.status_code == 200