I’m trying to make a password reset via email page following the tutorial here:
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Authentication#password_reset_templates
I can send emails while in the Python-Django shell but when I try to send it via that form, Gmail blocks my messages.
I have my email settings in settings.py configured as:
#gmail_send/settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'foo@gmail.com'
EMAIL_HOST_PASSWORD = os.environ('EMAIL_PASSWORD')
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
When I do this using the shell, I’m able to receive the email:
>>> from django.core.mail import send_mail
>>> send_mail('test email', 'hello world', 'your@email.com', ('test@email.com'))
My password reset form looks like this (base_generic just has some bootstrap and jquery CDN stuff along with a navbar)
{% extends "OracleOC/base_generic.html" %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
{% if form.email.errors %}
{{ form.email.errors }}
{% endif %}
<p>Please enter your email:</p>
<p>{{ form.email }}</p>
<input type="submit" class="btn btn-primary main_menu_button" value="Reset password">
</form>
{% endblock %}
When I press submit, everything looks fine and I get a
(17/Jan/2021 07:04:12) "GET /accounts/password_reset/done/ HTTP/1.1" 200 2105
in my Django console but I get a copy of the message in my sender gmail box with this message:
Gmail blocked my message!
No authentication error, Insecure Apps setting on.