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'
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.
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.
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.
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.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With