我正在尝试发送激活电子邮件并在Django中重置电子邮件。我正在使用Django注册模块,但注册后,页面返回到注册页面,并没有向我发送任何电子邮件。 部分 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
点击注册按钮后,浏览器会在此页面上等待2秒钟。
答案 0 :(得分:2)
你忘了添加
EMAIL_HOST = 'smtp.mysite.com'
发送电子邮件。
答案 1 :(得分:0)
如果使用cpanel,您必须先创建一个电子邮件帐户,然后转到设置邮件客户端,并在非SSL设置部分中写入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