settings
# 邮箱配置
EMAIL_HOST = 'smtp.qq.com'
EMAIL_PORT = 25 #发件箱的smtp服务器端口
EMAIL_HOST_USER = 'xxx@qq.com' # 你的 QQ 账号
EMAIL_HOST_PASSWORD = '秘钥'
EMAIL_USE_TLS = True # 这里必须是 True,否则发送不成功
EMAIL_FROM = 'xxx@qq.com' # 你的 QQ 账号
view.py
# 导入django内置发送邮件包
from django.core.mail import send_mail
email_title = '后台管理系统'
email_body = '登录成功!'
email = 'xxxx@qq.com' # 对方的邮箱
send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
评论 (0)