标签:use set 下载 send 服务 python message password 安装
1.生成token
下载安装itsdangerous模块
pip install itsdangerous
导入模块
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
2.发邮件
先找一个smtp服务器,授权smtp服务。
将配置写入setting.py
EMAIL_BACKEND = ‘django.core.mail.backends.smtp.EmailBackend‘ EMAIL_HOST = ‘smtp.163.com‘ EMAIL_PORT = 25 #发送邮件的邮箱 EMAIL_HOST_USER = ‘itcast88@163.com‘ #在邮箱中设置的客户端授权密码 EMAIL_HOST_PASSWORD = ‘python808‘ #收件人看到的发件人 EMAIL_FROM = ‘python<itcast88@163.com>‘
token = token.decode()
subject = ‘ttsx欢迎你‘ message = ‘‘; sender = settings.EMAIL_FROM recvlist = [email]
html_message = ‘<h1>%s ,欢迎你</h1><br>点击一下链接激活用户<a href="http:192.168.5.135:8000/user/active/%s">htttp:192.168.5.135:8000/user/active/%s</a>‘%(user.username, token, token) send_mail(subject, message, sender, recvlist, html_message=html_message)
标签:use set 下载 send 服务 python message password 安装
原文地址:https://www.cnblogs.com/yangzixiong/p/11691235.html