Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django registration email not sending

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 = '[email protected]'
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
like image 355
ThriceGood Avatar asked Apr 13 '15 22:04

ThriceGood


3 Answers

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 = '[email protected]'                              
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

like image 128
Nabarun Chatterjee Avatar answered Sep 29 '22 16:09

Nabarun Chatterjee


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.

like image 31
Jed Fox Avatar answered Sep 29 '22 15:09

Jed Fox


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',
    #...
]
like image 30
Slipstream Avatar answered Sep 29 '22 15:09

Slipstream