6

I've been trying to get the django-registration-redux account activation email to send to newly registered users.

I've gotten all non-email related parts to work, such as loggin in/out and actually registering the user! When i register, it automatically logs my in as that user. But i never get the activation email.

I've tried various different things to try get this to work, I've followed some tutorials on setting whole thing up but the emails still dont work.

heres some of the code setup, im using registration templates that i downloaded online.

settings.py

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'registration',
    'synths',
)


# user reg settings
REGISTRATION_OPEN = True
ACCOUNT_ACTIVATION_DAYS = 7
REGISTRATION_AUTO_LOGIN = True

LOGIN_REDIRECT_URL = '/'
LOGIN_URL = '/login/'

# i tried including this line but still nothing
# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# email
# first i tried setting up the debbuging server with this CMD line
# python -m smtpd -n -c DebuggingServer localhost:1025
# i dont know if it worked!, i got no errors but the cursor just
# sat there blinking at me! i was expecting some output to tell me
# the server had started
# these were the settings i used for that

EMAIL_HOST = '127.0.0.1'
EMAIL_PORT = 1025
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''

# then i tried using my own address and smtp.live.com

EMAIL_HOST = 'smtp.live.com'
EMAIL_PORT = 25
EMAIL_HOST_USER = 'myemailaddress@hotmail.com'
EMAIL_HOST_PASSWORD = '123123abcabc'

# still nothing

am i missing any important settings here?

urls.py

# included amongst my other urls
(r'^accounts/', include('registration.backends.simple.urls')),

seems all in order with the tutorials and documentation. like i said, registration works perfectly bar the emails.

one thing ive noticed is that you probably shouldn't have auto loggin = True if you want a user to activate their accounts, but commenting that line out didnt change anything, i still got logged in automatically after registering. Seems like a minor aside but maybe this has something to do with the emails not working?

i dunno, im lost with it. Either im missing some settings, the code doesnt work, python smtpd doesnt work, or my smtp.live.com settings are wrong!

any insigths greatly appreciated!

EDIT: when trying the 'reset password' email function i get this error

SMTPException at /accounts/password/reset/

SMTP AUTH extension not supported by server.

Request Method:     POST
Request URL:        http://localhost:8000/accounts/password/reset/
Django Version:     1.7.6
Exception Type:     SMTPException
Exception Value:    SMTP AUTH extension not supported by server.

Exception Location: C:\Python34\lib\smtplib.py in login, line 613
Python Executable:  C:\Python34\python.exe
Python Version:     3.4.3

EDIT 2: using these settings i get the the password/reset/done page but recieve no actual email

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

EMAIL_HOST = '127.0.0.1'
EMAIL_PORT = 1025
ThriceGood
  • 1,633
  • 3
  • 25
  • 43
  • Using the settings in your second edit, you shouldn't receive an actual email...the email should appear in your console. – rnevius Apr 14 '15 at 09:24
  • mevius is right. If you want to recieve an actual email, you need to put a SMTP as EMAIL_HOST. Also if you put your smtp and the same address for your new user registration, it might not show in Inbox, but will be in Sent. – jcs Apr 14 '15 at 16:48
  • its weird, i've tried it with the console backend, the smtp backend with the debuggserver with no luck. The settings were right for that. Then i tried with both the gmail and live smtp servers, the settings were right for that too, with TLS = true, and the PORT set to the correct tls port for the smtp. still no joy. im using the django-registration-redux, which works with python 3 and django 1.7, which is what i have. so this is confusing! – ThriceGood Apr 14 '15 at 19:13
  • I have the same problem. Password reset DOES work for me - I see the mail it in the console. I am using django 1.8, registration redux 1.2 and python 3.4. I think the problem is in the redux update to 1.2, but not really sure. Someone has probably forgotten to send the mail when the user is registered. In my case the user is also always automatically logged in after the registration is completed – maddob Jun 03 '15 at 23:34

4 Answers4

3
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

will only display the email on the console.

Instead you should use

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

Moreover it is more convenient to use a existing smtp server like gmail

For that you need to add these to your django settings file

EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'                                                                             
EMAIL_HOST ='smtp.gmail.com'                                   
EMAIL_PORT = 587                                                             
EMAIL_HOST_USER = 'youruser@gmail.com'                              
EMAIL_HOST_PASSWORD = 'gmail app password' #This is not your gmail password.
EMAIL_USE_TLS = True

More help on the password can be found here

Community
  • 1
  • 1
Nabarun Chatterjee
  • 1,084
  • 14
  • 17
  • Greeting .. your reference seems helpful. But after adding password reset functionality. Exception Type: SMTPServerDisconnected Exception Value: Connection unexpectedly closed. Error encounter But when I changed port to 465. The password reset functionality worked but register functionality didn't work. do the port have related with each other.. – Suman Astani Aug 27 '18 at 07:12
2

You may want to try adding a DEFAULT_FROM_EMAIL setting and setting these settings:

EMAIL_USE_TLS = True
EMAIL_USE_SSL = True

This will allow Django to use secure email-sending.

Jed Fox
  • 2,979
  • 5
  • 28
  • 38
1

Check your urls.py file, and make sure you are using the hmac not the simple

urlpatterns = [
    #...    
    url(r'^accounts/', include('registration.backends.hmac.urls')),
]

Also, in your setting.py, INSTALLED_APPS, make sure that the 'registration' is before django.contrib.auth.

INSTALLED_APPS = [
    #.....
    'registration',
    'django.contrib.auth',
    #...
]
Slipstream
  • 13,455
  • 3
  • 59
  • 45
0

I know this is an old question, but I thought it would help anybody else looking for the answer. You have setup your urlconf to use the one step registration. Below is a snippet from their docs -

This backend’s workflow is deliberately as simple as possible:

  1. A user signs up by filling out a registration form.
  2. The user’s account is created and is active immediately, with no intermediate confirmation or activation step.
  3. The new user is logged in immediately.

If you want to see the emails in the console, use the following urlconf instead -

url(r'^account/', include('registration.backends.default.urls')),

Hope that helps.