1. qq邮箱授权
2.settings配置
EMAIL_HOST = 'smtp.qq.com' EMAIL_PORT = 25 #发件箱的smtp服务器端口 EMAIL_HOST_USER = 'xxx@qq.com' # 你的 QQ 账号 EMAIL_HOST_PASSWORD = '刚刚复制的授权码(不是你的 QQ 密码!!!)' EMAIL_USE_TLS = True # 这里必须是 True,否则发送不成功 EMAIL_FROM = 'xxx@qq.com' # 你的 QQ 账号
3. views
from django.core.mail import send_mail email_title = '邮件标题' email_body = '邮件内容' email = 'xxx@xxx.com' #对方的邮箱 send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: # 发送成功