I have a view that creates accounts from user data in a CSV file. The users are able to log into their accounts. Allauth handles their authentication quite nicely. There is one problem though:
Password reset emails do not send for users created this way.
The users can start the recovery process, they can input their emails in the reset form, but after clicking the “reset button”, they do not get any emails to continue the process. Note that the process works perfectly for the superuser accounts. I suppose the later works because the superusers were created via the console using ./manage.py createsuperuser
How do I get the password reset emails to send for the generated accounts? I can confirm that the created accounts are active, have working email addresses and have usable passwords. What am I missing here? I want the users to take control of their own accounts by themselves.
Double/triple check the contents of the email field in the database. Make sure there are no extra spaces or other non-visible characters within that field. If necessary, dump the data back out using dumpdata
to see exactly what is present in that email address field.
I ran the following from the relevant django shell
from django.contrib.auth import get_user_model
[(u.email, u.is_active, u.has_usable_password()) for u in get_user_model().objects.all()]
Everything looks alright. Besides, user login is authenticating against the email addresses. If login works for those addresses, why are emails not sending for the same?
The next thing I can think of to check would be to compare every field in your user model between an account that works with one that doesn’t, to see what’s different between the two.
The issue is getting clearer. I forgot to specify the following in the project setting file:
EMAIL_HOST
EMAIL_PORT
EMAIL_HOST_USER
EMAIL_HOST_PASSWORD
EMAIL_USE_TLS
DEFAULT_FROM_EMAIL
But that is not the only issue – Adding those only brought out a more serious one. Now I get an error message for every time I ask allauth to send a password reset email.
On the browser I see:
"Server Error (500)"
On the server logs I get:
postfix/submission/smtpd[136633]: warning: TLS library problem: error:0A000412:SSL routines::sslv3 alert bad certificate:ssl/record/rec_layer_s3.c:1586:SSL alert number 42:
This is affecting all Django projects on the host now. It is new, all those projects were working perfectly. I thought this was a certificate issue. It is still happening after renewing all certificates.
Note:
Submission and associated auth via Email clients are still working. I can send mail from the server using mail
command. The error only shows up when a user requests a password reset from django/allauth. It now affects all users (including superusers)
Does anyone know where I can get information on how django-allauth handles email submission using TLS? It appears postfix-smtpd (server) is rejecting certificates from django-allauth.
I solved it. The solution is embarrassing. Here it is: