Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I figure out why django-allauth isn't sending a confirmation e-mail?

I am using Django-allauth and sending e-mail through Amazon SES. I want all accounts to verify their e-mails before they can log in, but the e-mail verification sending seems to fail silently. I've looked at the source code, where I saw I should set DEFAULT_FROM_EMAIL, but it still doesn't work.

Here's my config, in case I forgot anything obvious. I have django-smtp-ssl installed as email backend. Your help would 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 <[email protected]>'

# Auth

ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
SOCIALACCOUNT_EMAIL_VERIFICATION = True
ACCOUNT_AUTHENTICATION_METHOD = 'username_email'
like image 502
Benjamin Savoy Avatar asked Apr 24 '15 06:04

Benjamin Savoy


People also ask

How to look at all users in Django?

You can look at all users by navigating back to the admin panel at any time. django-allauth comes with a robust list of customizations we can add, including a logout link, requiring email confirmation, and much more. I encourage you to refer to the official docs from here for more information.

How to send an email in Django?

send_mail is an inbuilt Django function that takes subject, message, email_from, and recipient’s list as arguments, this is responsible to send emails. After these extra lines of code has been added to your project, you can send emails now.

How to set up Django-allauth to work correctly?

We need to make two updates to the admin for django-allauth to work correctly. First go to the Sites portion and set the domain name to 127.0.0.1. The Display Name is for internal admin use so we can leave it as is for now. When you deploy your Django application live you'd replace 127.0.0.1 here and on Github with your actual production homepage.

Does Django support third party authentication?

Django comes with a robust built-in authentication system for users but it does not provide support for third-party (social) authentication via services like Github, Gmail, or Facebook. Fortunately, the excellent 3rd party django-allauth package does in just a few steps.


1 Answers

Finally found what I was missing.

In my signup view, I added one more 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...
like image 118
Benjamin Savoy Avatar answered Oct 25 '22 16:10

Benjamin Savoy