我这个邮件发送功能还没实现,下面代码有点问题正在调试,不过基本代码如下,请问如何通过发送的这封邮件,要写什么才能实现邮件里面点击发送过去的链接更改密码的功能?
用户,密码保存在user_profile表当中
在view当中:
def send_mail(request): try: subject = 'hello' html_content = u'<b>激活链接:</b><a href="http://www.baidu.com">http:www.baidu.com</a>' msg = EmailMessage(subject,html_content,EMAIL_HOST_USER,['qq1183534511@sina.com',]) msg.content_subtype = 'html' msg.send() return(request,'common/resetpassword.html',locals()) except Exception as e: logger.error(e) return render(request,'common/error.html',{'error':e})
在settings当中
#邮件配置 EMAIL_HOST = 'smtp.sina.com' EMAIL_PORT = '25' EMAIL_HOST_USER = aaa@sina.com' EMAIL_HOST_PASSWORD = aaa' EMAIL_USE_TLS = True
def send_mail(request): try: if request.method == 'POST': email = request.POST.get('email',None) try: mail = UserProfile.objects.get(email = email) except Exception as e: logger.error(e) return render(request,'common/error.html',{'error':e}) subject = 'hello' html_content = u'<b>激活链接:</b><a href="http://127.0.0.1:8000/users/send_maiil/">修改密码</a>' msg = EmailMessage(subject,html_content,EMAIL_HOST_USER,[email,]) msg.content_subtype = 'html' msg.send() return render(request,'common/resetpassword.html',locals()) except Exception as e: logger.error(e) return render(request,'common/error.html',{'error':e})
请问如何传入这个随机字符串
html_content = u'<b>激活链接:</b><a href="http://127.0.0.1:8000/users/send_maiil/">修改密码</a>'
我将这个传入字符串用+加号拼接起来结果出错了,请问应该怎样将参数出入进去