Skip to content

Commit

Permalink
Merge pull request #81 from DjangoChinaOrg/yangxg
Browse files Browse the repository at this point in the history
腾讯企业邮箱邮件发送配置
  • Loading branch information
yangxg committed Jul 22, 2018
2 parents f39f23c + 71e7678 commit 792c5da
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion config/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DJANGO_DEBUG', True)
DEBUG = True

ALLOWED_HOSTS = []

Expand Down
48 changes: 36 additions & 12 deletions config/settings/production.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,51 @@
import os

from .common import *

DEBUG = False
ALLOWED_HOSTS = ['*']

SECRET_KEY = ''
ALLOWED_HOSTS = ['.dj-china.org', 'localhost', '127.0.0.1', '0.0.0.0']
SECRET_KEY = os.environ['DJANGO_SECRET_KEY']

# envs
MYSQL_HOST = os.getenv('MYSQL_PASSWORD')
MYSQL_DB_NAME = os.getenv('MYSQL_MYSQL_DB_NAME')
MYSQL_DB_USER = os.getenv('MYSQL_MYSQL_DB_USER')
MYSQL_PASSWORD = os.getenv('MYSQL_PASSWORD')

# sentry dsn
RAVEN_CONFIG = {
'dsn': os.environ.get('SENTRY_DSN', ''),
}

# 0: production
# 1: local test
local_test = os.environ.get('LOCAL_TEST', 0)

if local_test:
DEBUG = True
# sqlite3
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'dev.sqlite3'),
}
}
else:
# database
DATABASES['default'].update(
{'HOST': MYSQL_HOST,
'NAME': MYSQL_DB_NAME,
'USER': MYSQL_DB_USER,
'PASSWORD': MYSQL_PASSWORD,
})

# 邮件配置,使用腾讯云企业邮箱
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.exmail.qq.com'
EMAIL_PORT = 465
EMAIL_USE_SSL = True
EMAIL_USE_LOCALTIME = True
EMAIL_HOST_USER = 'master@dj-china.org'
EMAIL_HOST_PASSWORD = os.environ.get('DJANGO_EMAIL_HOST_PASSWORD', 'fallback_value')

# database
DATABASES['default'].update(
{'HOST': MYSQL_HOST,
'NAME': MYSQL_DB_NAME,
'USER': MYSQL_DB_USER,
'PASSWORD': MYSQL_PASSWORD,
})
# Default email address to use for various automated correspondence from the site manager(s).
DEFAULT_FROM_EMAIL = 'Django中文社区 <%s>' % EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER

0 comments on commit 792c5da

Please sign in to comment.