简体   繁体   中英

django-registration module dont send email

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 = 'info@mysite.com'
EMAIL_HOST_USER = 'info@mysite.com'
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.

在此处输入图片说明

You forget to add

EMAIL_HOST = 'smtp.mysite.com' 

to send email.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM