django邮件发送

需要一个邮箱,设置pop3

django邮件发送

django邮件发送

设置setting

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.163.com'
# EMAIL_USE_TLS = False
EMAIL_PORT = 465
EMAIL_USE_SSL = True # 发送邮件的邮箱
EMAIL_HOST_USER = 'peter_KRG@163.com'
# 在邮箱中设置的客户端授权密码
EMAIL_HOST_PASSWORD = 'XXXXXX'
# 收件人看到的发件人
EMAIL_FROM = '<peter_KRG@163.com>'

setting.py

设置views

from django_online import settings
from django.core.mail import send_mail def send_email_info():
subject = '主题' # 主题
message = 'this is test email' #内容
sender = settings.EMAIL_FROM # 发送邮箱,已经在settings.py设置,直接导入
receiver = ["73197823@qq.com"] # 目标邮箱
html_message = '<h1>%s</h1>' % "我就是有个测试信息" # 发送html格式
send_mail(subject, message, sender, receiver, html_message=html_message)
上一篇:python 项目实战之Django 邮件发送


下一篇:毕业设计——Django邮件发送功能实现及问题记录