Can someone explain how to set up email verification for django rest auth ? My settings.py contains:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
And I've added this line in my urls.py:
url(r'^accounts/', include('allauth.urls')),
But when I register with this endpoint: rest-auth/registration/
, the email is not sent, but the user is created.
What is the good configuration to send email confirmation? Do I have to have a SMTP server?
EDIT: (after @McAbra comment)
Obviously, this setting cannot send email:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
It only print the mail in the django console output.
The settings given by @McAbra works well.
But in a production environment, is it a good practice to send verification email with gmail?
Have I just to create email such noreply.myapp@gmail.com
?
EDIT 2:
My other problem is that the sent mail is empty. The template are presents in site-packages\allauth\templates\account\email
. The email title is [http://localhost:8000/]
but there is no content. I have no error in the python console. Any idea?
Solution for this point:
site-packages\allauth\templates\account\email
files must be copied inyour-app\templates\account\email
You need to have a SMTP server if you want to send real emails. I like to use Gmail SMTP server. settings.py
would be:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'gmail_username'
EMAIL_HOST_PASSWORD = 'password from https://security.google.com/settings/security/apppasswords'
Try from there. I'll try to help further if that doesn't help.