配置setting
#smtp服务器
EMAIL_HOST = "xxx"
EMAIL_PORT = 25
# 登录凭证SMTP服务器/填写自己邮箱
EMAIL_HOST_USER ="xxx"
EMAIL_HOST_PASSWORD = "19970123qaz"
#发送者邮箱最好与EMAIL_HOST_USER一致
EMAIL_FROM = "dengyaopersonal@aliyun.com"
#设置为True则为安全连接
EMAIL_USE_TSL = False
编写发送邮件函数
from django.core.mail import send_mail
from xxx.settings import EMAIL_FROM
def send_email(email):
title = "xxx"
body = "xxx"
send_status=send_mail(title,body,EMAIL_FROM,[email])
if send_status==1:
return 'ok'
return "error"
网友评论