Django-allauth: Confirmation email not sent after signing up

Created on 25 May 2015  Â·  11Comments  Â·  Source: pennersr/django-allauth

Hi everybody,

I've been following the instructions to set up the django-allauth package for my website and everything was working properly until the moment of sending a confirmation email after signing up. Everything seems to work fine because I sign up and the information about the new account is in the DB (user table and account_emailaddress) but the email is not sent (there is no content in the table account_emailconfirmation). EMAIL_BACKEND is set to 'django.core.mail.backends.console.EmailBackend' and I get no log errors so I don't know how to debug to find the error.

Thanks in advance.

Most helpful comment

I came across this thread while having the same problem; emails not sending.
The key was to change "django.core.mail.backends.console.EmailBackend" to be "...backends.smtp.EmailBackend"

All 11 comments

If all else fails, import pdb; pdb.set_trace() is your friend -- other than that, it is not viable for me to provide debugging support. Closing, feel free to reopen if you discover an issue in allauth.

Hello and thank you for your quick reply.

I've been debugging and I have noticed that the workflow is the one below:

  • The form_valid method inside SignupView calls to complete_signup
  • complete_signup calls to perform_login

Then, the first condition perform_login checks is "if not user.is_active" which I think is going to be always satisfied when signing up because a new user is not active by default. Because of this being satisfied, every user signing up is being redirected (return HttpResponseRedirect(reverse('account_inactive'))).

I have seen the comment:
# Local users are stopped due to form validation checking
# is_active, yet, adapter methods could toy with is_active in a
# user_signed_up signal. Furthermore, social users should be
# stopped anyway.

Does this mean I should implement something to get my confirmation email sent like the next?

@receiver(user_signed_up)
def after_user_signed_up(sender, request, user):
send_email_confirmation(request, user, signup=signup)

I guess the package works properly but I don't understand this works this way and I would appreciate your help.

Thanks again.

@pennersr I also encountered the same problem as @rserra90

My configuration:

ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USER_MODEL_USERNAME_FIELD = 'email'
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_USERNAME_REQUIRED = False

Should I send e-mail confirmations manually? Accounts are inactive by default and logic in allauth prevents e-mails from being sent at all.

Ok sorry, we had custom model with another defaults.

Thanks for the reply.

wt., 15.11.2016, 19:34 użytkownik Raymond Penners [email protected]
napisał:

Accounts are _active_ by default:

https://github.com/django/django/blob/master/django/contrib/auth/models.py#L328

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/pennersr/django-allauth/issues/962#issuecomment-260726238,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABrGvKkAZrmJMQJPFu8zFpld8fAQRjAMks5q-fstgaJpZM4Eo9NM
.

No problem. If for some reason it is important for you to deviate from Django standard behavior, I suggest you override the new_user method of the account adapter and explicitly set is_active to True there ...

I came across this thread while having the same problem; emails not sending.
The key was to change "django.core.mail.backends.console.EmailBackend" to be "...backends.smtp.EmailBackend"

If you are developing locally try changing EMAIL_BACKEND to ‘django.core.mail.backends.console.EmailBackend’. That will print your emails on the console so you can see them and get the verification links, but don't need a real email server setup just yet.

Otherwise, make sure you have your SMTP server setup. See the Django docs for all the settings you need to have set.

If you have the config set and it still isn't working I'd start by just trying to send an email through Django directly (the above link has examples) and that would help you figure out if it is Django-Allauth or a configuration or other issue with your SMTP server.

If you are developing locally try changing EMAIL_BACKEND to ‘django.core.mail.backends.console.EmailBackend’. That will print your emails on the console so you can see them and get the verification links, but don't need a real email server setup just yet.

Otherwise, make sure you have your SMTP server setup. See the Django docs for all the settings you need to have set.

If you have the config set and it still isn't working I'd start by just trying to send an email through Django directly (the above link has examples) and that would help you figure out if it is Django-Allauth or a configuration or other issue with your SMTP server.

I use these settings and don’t understand why messages are not sent through your library. Django's standard facilities send them

EMAIL_HOST = 'somehost.com'
EMAIL_PORT = 25 # i use other
EMAIL_HOST_USER = 'someusername'
EMAIL_HOST_PASSWORD = 'passwd'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_AUTHENTICATION_METHOD = "email"
ACCOUNT_CONFIRM_EMAIL_ON_GET = True
ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = reverse_lazy('account_confirm_complete')
ACCOUNT_EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL = reverse_lazy('account_confirm_complete')
ACCOUNT_USERNAME_REQUIRED = True

any solution?

I came across this thread while having the same problem; emails not sending.
The key was to change "django.core.mail.backends.console.EmailBackend" to be "...backends.smtp.EmailBackend"

Took a while to notice this change. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nlubega picture nlubega  Â·  4Comments

dollydagr picture dollydagr  Â·  4Comments

psychok7 picture psychok7  Â·  5Comments

hyunwoona picture hyunwoona  Â·  4Comments

slimaidarismail picture slimaidarismail  Â·  3Comments