Я пытаюсь отправить электронное письмо, когда пользователь регистрируется, но он просто перенаправляет на ожидаемую страницу, но без отправки электронного письма.
Вот мой код
def register_view(request): # Creates a New Account & login New users
if request.user.is_authenticated:
return redirect("/")
else:
title = "Register"
form = UserRegistrationForm(request.POST or None)
print(form.is_valid())
if form.is_valid():
user = form.save(commit=False)
password = form.cleaned_data.get("password1")
user.set_password(password)
user.save()
# new_user = authenticate(email=user.email, password=password)
login(request, user)
return redirect("/books")
subject = "Greetings"
msg = "Congratulations Yor Account is created Successfully. Do not share your login credentials with anyone else"
to = "Ak4695755@gmail.com"
res = send_mail(subject, msg, settings.EMAIL_HOST_USER, [to])
context = {"title": title, "form": form}
return render(request, "accounts/signup.html", context)