Django发送邮件代理服务器配置

根路由下配置

MAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.qq.com'
EMAIL_HOST_USER = '66897079@qq.com'
EMAIL_HOST_PASSWORD = 'aavlzhzvqorbcahc'

EMAIL_PORT = 465
EMAIL_USE_SSL = True

发送邮件

    message = "<p>尊敬的用户您好:</p><p>欢迎注册达达商城。</p>"
    from django.core.mail import send_mail

    send_mail(
        subject="Subject",
        message=None,
        from_email='66897079@qq.com',
        recipient_list=['66897079@qq.com'],
        html_message=message
    )

另外
message可以用render_to_string渲染
此时,需要添加templates配置

TEMPLATES = [
	{
		.......
		'DIRS': [BASE_DIR / 'templates'],
		......
	}
]
上一篇:论文阅读笔记- Language Modeling with Gated Convolutional Networks-总结


下一篇:大数据新视界 --大数据大厂之大数据驱动下的物流供应链优化:实时追踪与智能调配-结束语: