wd-smebiz/utils/email_utils.py

25 lines
647 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://email_api:30001",
sender="dogbillions@163.com"):
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