参考文章:https://github.com/CDOT-EDX/ProductionStackDocs/wiki/Enable-SMTP-for-EDX-(Production-Stack)
具体到生产或开发环境做的事情:
1.修改文件:
lms/envs/content.py Line15 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
cms/envs/devstack.py Line26 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
lms/envs/devstack.py Line30 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
cms/envs/common.py Line360 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
lms/envs/common.py Line730 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
将以上 'django.core.mail.backends.console.EmailBackend'改成 'django.core.mail.backends.smtp.EmailBackend'
(以下以163邮箱为例,如果是其他邮箱,注意开启邮箱的SMTP和POP服务,并查下SMTP端口是多少,163 smtp 非ssh端口为25)
2.修改环境变量
a. cms.env.json
"DEFAULT_FROM_EMAIL": "xxxxx@163.com",
"EMAIL_BACKEND": "django.core.mail.backends.smtp.EmailBackend",
"EMAIL_HOST": "smtp.163.com",
"EMAIL_PORT": 25,
"EMAIL_USE_TLS": True,
b. cms.auth.json
"EMAIL_HOST_PASSWORD": "邮箱的真实密码",
"EMAIL_HOST_USER": "xxxxx@163.com",
c. lms.env.json
"DEFAULT_FROM_EMAIL": "xxxxx@163.com",
"EMAIL_BACKEND": "django.core.mail.backends.smtp.EmailBackend",
"EMAIL_HOST": "smtp.163.com",
"EMAIL_PORT": 25,
"EMAIL_USE_TLS": true,
d. lms.auth.json
"EMAIL_HOST_PASSWORD": "邮箱的真实密码",
"EMAIL_HOST_USER": "xxxxx@163.com",
3.修改配置文件
/devstack/edx-platform/cms/envs/common.py
EMAIL_HOST = 'smtp.163.com'
EMAIL_PORT = 25
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'xxxxx@163.com'
EMAIL_HOST_PASSWORD = '邮箱的真实密码'
DEFAULT_FROM_EMAIL = 'xxxxx@163.com'
DEFAULT_FEEDBACK_EMAIL = 'xxxxx@163.com'
SERVER_EMAIL = 'xxxxx@163.com'
/devstack/edx-platform/lms/envs/aws.py
EMAIL_HOST = ENV_TOKENS.get('EMAIL_HOST', 'smtp.163.com') # django default is localhost
EMAIL_PORT = ENV_TOKENS.get('EMAIL_PORT', 25) # django default is 25
EMAIL_USE_TLS = ENV_TOKENS.get('EMAIL_USE_TLS', True) # django default is False
...
EMAIL_HOST_USER = AUTH_TOKENS.get('EMAIL_HOST_USER', 'xxxxx@163.com') # django default is ''
EMAIL_HOST_PASSWORD = AUTH_TOKENS.get('EMAIL_HOST_PASSWORD', '邮箱的真实密码') # django default is ''