1.在163邮箱中开启
2.django视图中导入邮件发送模块
from django.core.mail import send_mail
3.在setting中配置发送配置
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.163.com'
EMAIL_PORT = 25
EMAIL_HOST_USER = '邮箱名'
EMAIL_HOST_PASSWORD = '获得的授权码'
EMAIL_FROM = '别名<邮箱>'
4.在视图函数中调用
from django.conf import setting
subject = "邮件主题"
sender = setting.EMAIL_HOST_USER
message = "邮件内容"
receiver = [收件人邮箱列表]
html_message = "以HTML格式显示的邮件内容"
send_mail(subject, message, from_mail=sender, recipient=receiver, html_message=html_message)