1.选择发送邮箱并设置SMTP许可
例163
2.Setting配置
# 发送邮件配置 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend # 服务器名称 EMAIL_HOST = 'smtp.office365.com' # 服务端口 EMAIL_PORT = 587 # 邮箱 EMAIL_HOST_USER = 'Jrri@outlook.com' # 在邮箱中设置的客户端授权密码 EMAIL_HOST_PASSWORD = 'PassWord' #收件人看到的发件人 EMAIL_FROM = 'Jrri<Jrri@outlook.com>'
3.使用导入Django模块email,并使用
from django.core.mail import send_mail subject = 邮件主题 message = '文字内容' from_email = 发送人(同Setting/EMAIL_FROM) recipient_list = [收件人1, 收件人2, ...] html_message = '带有H5标签的消息内容' send_mail(subject, message, from_email, recipient_list, html_message=)