I am unable to use django's default password_reset
. It isn't sending emails. I have tried many many configurations but nothing is working.
I know my settings are right, As I am fully able to send emails in views.py
Following Code is absolutely working.
from django.core.mail import send_mail
def contact_us(request):
contact_form = ContactForm(request.POST or None)
context = {
"form": contact_form,
}
if contact_form.is_valid():
print(contact_form.cleaned_data)
send_mail(
'Contacted By: {}'.format(contact_form.cleaned_data.get('name')),
contact_form.cleaned_data.get('comment'),
'mydjangoemail@gmail.com',
['customerfeedback@gmail.com',],
fail_silently=False,
)
if request.is_ajax():
return JsonResponse({"message": "Thanks"})
if contact_form.errors:
errors = contact_form.errors.as_json()
if request.is_ajax():
return HttpResponse(errors, status=400, content_type='application/json')
return redirect("App:home")
My above is working but I don't what is wrong with following code that
password_reset
not sending emails
I am using django's default password_reset by using following in project's urls.py
, I am accessing all templates
like password_reset
at http://127.0.0.1:8000/accounts/password_reset/:
path('accounts/', include('django.contrib.auth.urls')),
templates
are working fine too:
my settings.py
has following email config:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'mydjangoemail@gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 25
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'mydjangoemail@gmail.com'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
MANAGERS = (
('Abc', "mydjangoemail@gmail.com"),
)
ADMINS = MANAGERS
And 'django.contrib.auth'
is also in INSTALLED_APPS
.