Forums

Django-registration email wont send.

Im using the django-registration package (http://django-registration.readthedocs.org/en/latest/index.html), with two step registration. Part of the workflow is to send an email to the user with an activation key. I have the registration view included and the user is being created as expected. However, the email is not being sent, and no error message are being thrown either. My email settings are as follows:

EMAIL_BACKEND ='django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = "smtp.gmail.com"
EMAIL_HOST_USER = "username@gmail.com"
EMAIL_HOST_PASSWORD = '****'
EMAIL_PORT = 587
EMAIL_USE_TLS = True

Im confirming the user is being created using the following test:

def test_user_reg(self):
    c = Client()
    c.post('/register/',{'username':'Michael','password':'password',\
    'email':'email@gmail.com'})
    user = User.objects.get(username='Michael')
    self.assertFalse(user.is_active)

I have noticed that I can change any of the settings without the test failing or any errors being thrown. I am sure that the emil sending method of django-registration is being called, as an error is thrown if I remove the email templates it requires. Any help would be greatly appreciated.

One possibility is that GMail are blocking the access because of your security settings -- sometimes you have to unlock it. This page should help.

Tried that and nothing changed. I checked my account security settings and there doesnt seem to have been any attempt made to log in to the site, based on the log of events on the account.

Nevermind. Sorted it.

What was it? Posting the fix here might help others who have similar problems.