0

I have implemented the reset password functionality using Django. Here I am sending the reset password link to registered email and no mail is coming to the inbox. My code is below.

settings.py:

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = '*********'
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = '[email protected]'

registration/password_reset_form.html:

{% extends 'base.html' %}

{% block content %}
  <h3>Forgot password</h3>
  <form method="post">
    {% csrf_token %}
    {{ form.as_p }}
    <button type="submit">Submit</button>
  </form>
{% endblock %}

registration/password_reset_email.html:

    {% autoescape off %}
    To initiate the password reset process for your {{ user.get_username }} TestSite Account,
    click the link below:

    {{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}

If clicking the link above doesn't work, please copy and paste the URL in a new browser
window instead.

Sincerely,
The Nuclear Team
{% endautoescape %}

My password reset form looks like below.

enter image description here

Here I could not send the mail to the given email id.

8
  • 1
    Can you show us your view for password reset? Commented Aug 12, 2017 at 9:37
  • 2
    Just read the docs. Your first line of code is wrong. docs.djangoproject.com/en/1.11/topics/email/#console-backend Commented Aug 12, 2017 at 9:44
  • It does not send mail because the mail is printed to console. Like you configured it. Commented Aug 12, 2017 at 9:44
  • @Wencakisa : I attched the screen shot for the form. Commented Aug 12, 2017 at 9:44
  • @satya view mean views.py code where your reset action Commented Aug 12, 2017 at 9:47

2 Answers 2

2

Yiu need replace:

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
#                                        ^^^^^^^^

to

BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
#                                   ^^^^^^

more info here: email-backend

Sign up to request clarification or add additional context in comments.

3 Comments

I did it but still this SMTP AUTH extension not supported by server. error coming.
does you input correct email? did your redirect on reset done?
It worked I just changed EMAIL_USE_TLS = True.Thanks
0

You should have on your views something like:

from django.core.mail import EmailMessage

email = EmailMessage('title', 'body', to=[email])
email.send()

Also you need to unlock captcha on your gmail account: https://accounts.google.com/DisplayUnlockCaptcha

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.