django-registration module dont send email

368 views Asked by At

I am trying to send activation email and reset email in Django. I am using Django registration module but after registration, the page returned back to the registration page and did not send any email to me. Part of settings.py :

DEBUG = False

ALLOWED_HOSTS = ['mysite.com', 'www.mysite.com']

EMAIL_BACKEND ='django.core.mail.backends.smtp.EmailBackend' 
DEFAULT_FROM_EMAIL = '[email protected]'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'my pass'
EMAIL_USE_TLS = True 
EMAIL_PORT = 1025

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'posts',
    'registration',
    'django_countries',
    'crispy_forms',
    'django_forms_bootstrap',
    'captcha', 
   ]

ACCOUNT_ACTIVATION_DAYS = 7
REGISTRATION_AUTO_LOGIN = True
SITE_ID = 1

After clicking on the register button, browser waits for 2 seconds on this page.

enter image description here

2

There are 2 answers

2
Mahendra Garg On BEST ANSWER

You forget to add

EMAIL_HOST = 'smtp.mysite.com' 

to send email.

0
Masume Ebhami On

if use cpanel you must first create a email account and then go to Set Up Mail Clien and in Non-SSL Settings section write the outgoing server and port in settings.py

 EMAIL_BACKEND ='django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'outgoingserver'
EMAIL_PORT = SMTP_port
DEFAULT_FROM_EMAIL = 'your email account'
EMAIL_HOST_USER = 'your email account'
EMAIL_HOST_PASSWORD = 'email password'
EMAIL_USE_TLS = True