Reputation: 4667
So, I'm using django-registration in my project to enable user self-registration in the app I'm building. I've configured django-registration to send confirmation emails to the registered users.
My settings.py
:
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'apassword'
...
ACCOUNT_ACTIVATION_DAYS = 7
But, after the user fills the registration form and clicks the register button, the page keeps waiting for the email sending process. It looks like the response (the confirmation page) is received only after the email has been sent.
I've read another thread that shows how to send an email in a thread. Is there a way to send emails, using django-registration, in such a way that the response for the form registration submit doesn't keep blocked until the email is sent? I mean, I don't want to modify the django-registration
itself.
Upvotes: 6
Views: 1657
Reputation: 9568
You should make use of Django Mailer to queue the sending of emails.
Alternatively you could use Celery with Django to queue up your emails to the SMTP server or use Amazon SES
from registration.signals import user_activated, user_registered
user_registered.connect(<Hook your add email to celery task queue> )
Upvotes: 4