以下是我写的视图,没有发生错误,但没有邮件被发送到receiver_email地址。
def register_user(request):
username = request.POST['username']
first_name = request.POST['first_name']
last_name = request.POST['last_name']
receiver_email = request.POST['email']
passwd = generate_passwd()
user = User.objects.create_user(username=username,password=passwd,email=email,first_name=first_name,last_name=last_name)
res = send_mail("password",passwd,"theanirbanacharya@gmail.com",receiver_email)
return HttpResponseRedirect(reverse('polls:login',args=()))
我正在做的是生成一个我希望邮寄给用户的随机密码(发送到receiver_email)。但当我点击“注册”按钮时没有任何反应,请求没有得到处理。并非负责注册的模板有任何问题。
答案 0 :(得分:0)
您是否在{。3}}设置中添加了settings.py文件?例如,gmail设置如下:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'youremail@gmail.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_USE_TLS = 1