How can I figure out why django-allauth is not sending the confirmation email?
I am using Django-allauth and am sending email via Amazon SAS. I want all accounts to check their emails before they can log in, but sending confirmation email seems to fail. I looked at the source code where I saw I should set DEFAULT_FROM_EMAIL, but it still doesn't work.
Here's my configuration, in case I've forgotten anything obvious. I have django-smtp-ssl installed as a mail server. Your help will be much appreciated!
# E-mail
EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'
EMAIL_HOST = 'email-smtp.us-west-2.amazonaws.com'
EMAIL_HOST_USER = os.environ['EMAIL_USER']
EMAIL_HOST_PASSWORD = os.environ['EMAIL_PASSWORD']
EMAIL_PORT = 465
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'Verified-email <verified-ses-email@example.com>'
# Auth
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
SOCIALACCOUNT_EMAIL_VERIFICATION = True
ACCOUNT_AUTHENTICATION_METHOD = 'username_email'
+3
source to share
2 answers
Finally found what was missing.
In my registration view, I added another line:
from allauth.account.utils import complete_signup
from allauth.account import app_settings
# some other code
def signup(request):
if request.method == 'POST':
form = UserCreateForm(request.POST)
if form.is_valid():
user = form.save(request)
# Added this!
complete_signup(request, user,app_settings.EMAIL_VERIFICATION, "/")
# etc...
+1
source to share
DEFAULT_FROM_EMAIL
must be a valid address on EMAIL_HOST
.
And you can also check it as below.
$ python manage.py shell
Python 2.7.9 (default, Jun 29 2016, 13:08:31)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.conf import settings
>>> settings.EMAIL_BACKEND
'django.core.mail.backends.smtp.EmailBackend'
>>> from django.core.mail import send_mail
>>> send_mail('test message', 'this is a test message', settings.DEFAULT_FROM_EMAIL, ['recipient@example.com'])
1
>>>
0
source to share