prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Just email console backend in development mode
  When EMAIL_HOST is setted and DEBUG is True email continue on console
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `bothub/settings.py`
  Content:
  ```
  1 import os
  2 import dj_database_url
  3 
  4 from decouple import config
  5 
  6 
  7 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  8 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  9 
  10 
  11 # SECURITY WARNING: keep the secret key used in production secret!
  12 SECRET_KEY = config('SECRET_KEY')
  13 
  14 # SECURITY WARNING: don't run with debug turned on in production!
  15 DEBUG = config('DEBUG', default=False, cast=bool)
  16 
  17 ALLOWED_HOSTS = config(
  18     'ALLOWED_HOSTS',
  19     default='*',
  20     cast=lambda v: [s.strip() for s in v.split(',')])
  21 
  22 
  23 # Application definition
  24 
  25 INSTALLED_APPS = [
  26     'django.contrib.admin',
  27     'django.contrib.auth',
  28     'django.contrib.contenttypes',
  29     'django.contrib.sessions',
  30     'django.contrib.messages',
  31     'django.contrib.staticfiles',
  32     'rest_framework',
  33     'rest_framework.authtoken',
  34     'django_filters',
  35     'corsheaders',
  36     'bothub.authentication',
  37     'bothub.common',
  38     'bothub.api',
  39 ]
  40 
  41 MIDDLEWARE = [
  42     'django.middleware.security.SecurityMiddleware',
  43     'whitenoise.middleware.WhiteNoiseMiddleware',
  44     'django.contrib.sessions.middleware.SessionMiddleware',
  45     'corsheaders.middleware.CorsMiddleware',
  46     'django.middleware.common.CommonMiddleware',
  47     'django.middleware.csrf.CsrfViewMiddleware',
  48     'django.contrib.auth.middleware.AuthenticationMiddleware',
  49     'django.contrib.messages.middleware.MessageMiddleware',
  50     'django.middleware.clickjacking.XFrameOptionsMiddleware',
  51 ]
  52 
  53 ROOT_URLCONF = 'bothub.urls'
  54 
  55 TEMPLATES = [
  56     {
  57         'BACKEND': 'django.template.backends.django.DjangoTemplates',
  58         'DIRS': [],
  59         'APP_DIRS': True,
  60         'OPTIONS': {
  61             'context_processors': [
  62                 'django.template.context_processors.debug',
  63                 'django.template.context_processors.request',
  64                 'django.contrib.auth.context_processors.auth',
  65                 'django.contrib.messages.context_processors.messages',
  66             ],
  67         },
  68     },
  69 ]
  70 
  71 WSGI_APPLICATION = 'bothub.wsgi.application'
  72 
  73 
  74 # Database
  75 
  76 DATABASES = {}
  77 DATABASES['default'] = dj_database_url.parse(
  78     config(
  79         'DEFAULT_DATABASE',
  80         default='sqlite:///db.sqlite3'))
  81 
  82 
  83 # Auth
  84 
  85 AUTH_USER_MODEL = 'authentication.User'
  86 
  87 
  88 # Password validation
  89 
  90 AUTH_PASSWORD_VALIDATORS = [
  91     {
  92         'NAME': 'django.contrib.auth.password_validation.' +
  93         'UserAttributeSimilarityValidator',
  94     },
  95     {
  96         'NAME': 'django.contrib.auth.password_validation.' +
  97         'MinimumLengthValidator',
  98     },
  99     {
  100         'NAME': 'django.contrib.auth.password_validation.' +
  101         'CommonPasswordValidator',
  102     },
  103     {
  104         'NAME': 'django.contrib.auth.password_validation.' +
  105         'NumericPasswordValidator',
  106     },
  107 ]
  108 
  109 
  110 # Internationalization
  111 
  112 LANGUAGE_CODE = config('LANGUAGE_CODE', default='en-us')
  113 
  114 TIME_ZONE = config('TIME_ZONE', default='UTC')
  115 
  116 USE_I18N = True
  117 
  118 USE_L10N = True
  119 
  120 USE_TZ = True
  121 
  122 
  123 # Static files (CSS, JavaScript, Images)
  124 
  125 STATIC_URL = '/static/'
  126 
  127 STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
  128 
  129 STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
  130 
  131 
  132 # rest framework
  133 
  134 REST_FRAMEWORK = {
  135     'DEFAULT_AUTHENTICATION_CLASSES': [
  136         'rest_framework.authentication.TokenAuthentication',
  137     ],
  138     'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.' +
  139     'LimitOffsetPagination',
  140     'PAGE_SIZE': 20,
  141     'DEFAULT_FILTER_BACKENDS': [
  142         'django_filters.rest_framework.DjangoFilterBackend',
  143     ],
  144     'DEFAULT_METADATA_CLASS': 'bothub.api.metadata.Metadata',
  145 }
  146 
  147 
  148 # cors headers
  149 
  150 CORS_ORIGIN_ALLOW_ALL = True
  151 CORS_URLS_REGEX = r'^/api/.*$'
  152 
  153 
  154 # mail
  155 
  156 envvar_EMAIL_HOST = config('EMAIL_HOST', default=None)
  157 
  158 ADMINS = config(
  159     'ADMINS',
  160     default='',
  161     cast=lambda v: [
  162         (
  163             s.strip().split('|')[0],
  164             s.strip().split('|')[1],
  165         ) for s in v.split(',')] if v else [])
  166 EMAIL_SUBJECT_PREFIX = '[bothub] '
  167 DEFAULT_FROM_EMAIL = config(
  168     'DEFAULT_FROM_EMAIL',
  169     default='webmaster@localhost')
  170 SERVER_EMAIL = config('SERVER_EMAIL', default='root@localhost')
  171 
  172 if not DEBUG and envvar_EMAIL_HOST:
  173     EMAIL_HOST = envvar_EMAIL_HOST
  174     EMAIL_PORT = config('EMAIL_PORT', default=25, cast=int)
  175     EMAIL_HOST_USER = config('EMAIL_HOST_USER', default='')
  176     EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD', default='')
  177     EMAIL_USE_SSL = config('EMAIL_USE_SSL', default=False, cast=bool)
  178     EMAIL_USE_TLS = config('EMAIL_USE_TLS', default=False, cast=bool)
  179 else:
  180     EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  181 
  182 
  183 # webapp
  184 
  185 BOTHUB_WEBAPP_BASE_URL = config(
  186     'BOTHUB_WEBAPP_BASE_URL',
  187     default='http://localhost:8080/')
  188 
  189 
  190 # NLP
  191 
  192 BOTHUB_NLP_BASE_URL = config(
  193     'BOTHUB_NLP_BASE_URL',
  194     default='http://localhost:8001/')
  195 
  196 
  197 # CSRF
  198 
  199 CSRF_COOKIE_DOMAIN = config(
  200     'CSRF_COOKIE_DOMAIN',
  201     default=None)
  202 
  203 CSRF_COOKIE_SECURE = config(
  204     'CSRF_COOKIE_SECURE',
  205     default=False,
  206     cast=bool)
  207
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/bothub/settings.py b/bothub/settings.py
  --- a/bothub/settings.py
  +++ b/bothub/settings.py
  @@ -169,7 +169,7 @@
       default='webmaster@localhost')
   SERVER_EMAIL = config('SERVER_EMAIL', default='root@localhost')
   
  -if not DEBUG and envvar_EMAIL_HOST:
  +if envvar_EMAIL_HOST:
       EMAIL_HOST = envvar_EMAIL_HOST
       EMAIL_PORT = config('EMAIL_PORT', default=25, cast=int)
       EMAIL_HOST_USER = config('EMAIL_HOST_USER', default='')
  
verification_info: {"golden_diff": "diff --git a/bothub/settings.py b/bothub/settings.py\n--- a/bothub/settings.py\n+++ b/bothub/settings.py\n@@ -169,7 +169,7 @@\n     default='webmaster@localhost')\n SERVER_EMAIL = config('SERVER_EMAIL', default='root@localhost')\n \n-if not DEBUG and envvar_EMAIL_HOST:\n+if envvar_EMAIL_HOST:\n     EMAIL_HOST = envvar_EMAIL_HOST\n     EMAIL_PORT = config('EMAIL_PORT', default=25, cast=int)\n     EMAIL_HOST_USER = config('EMAIL_HOST_USER', default='')\n", "issue": "Just email console backend in development mode\nWhen EMAIL_HOST is setted and DEBUG is True email continue on console\n", "before_files": [{"content": "import os\nimport dj_database_url\n\nfrom decouple import config\n\n\n# Build paths inside the project like this: os.path.join(BASE_DIR, ...)\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEY = config('SECRET_KEY')\n\n# SECURITY WARNING: don't run with debug turned on in production!\nDEBUG = config('DEBUG', default=False, cast=bool)\n\nALLOWED_HOSTS = config(\n    'ALLOWED_HOSTS',\n    default='*',\n    cast=lambda v: [s.strip() for s in v.split(',')])\n\n\n# Application definition\n\nINSTALLED_APPS = [\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n    'rest_framework',\n    'rest_framework.authtoken',\n    'django_filters',\n    'corsheaders',\n    'bothub.authentication',\n    'bothub.common',\n    'bothub.api',\n]\n\nMIDDLEWARE = [\n    'django.middleware.security.SecurityMiddleware',\n    'whitenoise.middleware.WhiteNoiseMiddleware',\n    'django.contrib.sessions.middleware.SessionMiddleware',\n    'corsheaders.middleware.CorsMiddleware',\n    'django.middleware.common.CommonMiddleware',\n    'django.middleware.csrf.CsrfViewMiddleware',\n    'django.contrib.auth.middleware.AuthenticationMiddleware',\n    'django.contrib.messages.middleware.MessageMiddleware',\n    'django.middleware.clickjacking.XFrameOptionsMiddleware',\n]\n\nROOT_URLCONF = 'bothub.urls'\n\nTEMPLATES = [\n    {\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\n        'DIRS': [],\n        'APP_DIRS': True,\n        'OPTIONS': {\n            'context_processors': [\n                'django.template.context_processors.debug',\n                'django.template.context_processors.request',\n                'django.contrib.auth.context_processors.auth',\n                'django.contrib.messages.context_processors.messages',\n            ],\n        },\n    },\n]\n\nWSGI_APPLICATION = 'bothub.wsgi.application'\n\n\n# Database\n\nDATABASES = {}\nDATABASES['default'] = dj_database_url.parse(\n    config(\n        'DEFAULT_DATABASE',\n        default='sqlite:///db.sqlite3'))\n\n\n# Auth\n\nAUTH_USER_MODEL = 'authentication.User'\n\n\n# Password validation\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        'NAME': 'django.contrib.auth.password_validation.' +\n        'UserAttributeSimilarityValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.' +\n        'MinimumLengthValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.' +\n        'CommonPasswordValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.' +\n        'NumericPasswordValidator',\n    },\n]\n\n\n# Internationalization\n\nLANGUAGE_CODE = config('LANGUAGE_CODE', default='en-us')\n\nTIME_ZONE = config('TIME_ZONE', default='UTC')\n\nUSE_I18N = True\n\nUSE_L10N = True\n\nUSE_TZ = True\n\n\n# Static files (CSS, JavaScript, Images)\n\nSTATIC_URL = '/static/'\n\nSTATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')\n\nSTATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'\n\n\n# rest framework\n\nREST_FRAMEWORK = {\n    'DEFAULT_AUTHENTICATION_CLASSES': [\n        'rest_framework.authentication.TokenAuthentication',\n    ],\n    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.' +\n    'LimitOffsetPagination',\n    'PAGE_SIZE': 20,\n    'DEFAULT_FILTER_BACKENDS': [\n        'django_filters.rest_framework.DjangoFilterBackend',\n    ],\n    'DEFAULT_METADATA_CLASS': 'bothub.api.metadata.Metadata',\n}\n\n\n# cors headers\n\nCORS_ORIGIN_ALLOW_ALL = True\nCORS_URLS_REGEX = r'^/api/.*$'\n\n\n# mail\n\nenvvar_EMAIL_HOST = config('EMAIL_HOST', default=None)\n\nADMINS = config(\n    'ADMINS',\n    default='',\n    cast=lambda v: [\n        (\n            s.strip().split('|')[0],\n            s.strip().split('|')[1],\n        ) for s in v.split(',')] if v else [])\nEMAIL_SUBJECT_PREFIX = '[bothub] '\nDEFAULT_FROM_EMAIL = config(\n    'DEFAULT_FROM_EMAIL',\n    default='webmaster@localhost')\nSERVER_EMAIL = config('SERVER_EMAIL', default='root@localhost')\n\nif not DEBUG and envvar_EMAIL_HOST:\n    EMAIL_HOST = envvar_EMAIL_HOST\n    EMAIL_PORT = config('EMAIL_PORT', default=25, cast=int)\n    EMAIL_HOST_USER = config('EMAIL_HOST_USER', default='')\n    EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD', default='')\n    EMAIL_USE_SSL = config('EMAIL_USE_SSL', default=False, cast=bool)\n    EMAIL_USE_TLS = config('EMAIL_USE_TLS', default=False, cast=bool)\nelse:\n    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'\n\n\n# webapp\n\nBOTHUB_WEBAPP_BASE_URL = config(\n    'BOTHUB_WEBAPP_BASE_URL',\n    default='http://localhost:8080/')\n\n\n# NLP\n\nBOTHUB_NLP_BASE_URL = config(\n    'BOTHUB_NLP_BASE_URL',\n    default='http://localhost:8001/')\n\n\n# CSRF\n\nCSRF_COOKIE_DOMAIN = config(\n    'CSRF_COOKIE_DOMAIN',\n    default=None)\n\nCSRF_COOKIE_SECURE = config(\n    'CSRF_COOKIE_SECURE',\n    default=False,\n    cast=bool)\n", "path": "bothub/settings.py"}], "after_files": [{"content": "import os\nimport dj_database_url\n\nfrom decouple import config\n\n\n# Build paths inside the project like this: os.path.join(BASE_DIR, ...)\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEY = config('SECRET_KEY')\n\n# SECURITY WARNING: don't run with debug turned on in production!\nDEBUG = config('DEBUG', default=False, cast=bool)\n\nALLOWED_HOSTS = config(\n    'ALLOWED_HOSTS',\n    default='*',\n    cast=lambda v: [s.strip() for s in v.split(',')])\n\n\n# Application definition\n\nINSTALLED_APPS = [\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n    'rest_framework',\n    'rest_framework.authtoken',\n    'django_filters',\n    'corsheaders',\n    'bothub.authentication',\n    'bothub.common',\n    'bothub.api',\n]\n\nMIDDLEWARE = [\n    'django.middleware.security.SecurityMiddleware',\n    'whitenoise.middleware.WhiteNoiseMiddleware',\n    'django.contrib.sessions.middleware.SessionMiddleware',\n    'corsheaders.middleware.CorsMiddleware',\n    'django.middleware.common.CommonMiddleware',\n    'django.middleware.csrf.CsrfViewMiddleware',\n    'django.contrib.auth.middleware.AuthenticationMiddleware',\n    'django.contrib.messages.middleware.MessageMiddleware',\n    'django.middleware.clickjacking.XFrameOptionsMiddleware',\n]\n\nROOT_URLCONF = 'bothub.urls'\n\nTEMPLATES = [\n    {\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\n        'DIRS': [],\n        'APP_DIRS': True,\n        'OPTIONS': {\n            'context_processors': [\n                'django.template.context_processors.debug',\n                'django.template.context_processors.request',\n                'django.contrib.auth.context_processors.auth',\n                'django.contrib.messages.context_processors.messages',\n            ],\n        },\n    },\n]\n\nWSGI_APPLICATION = 'bothub.wsgi.application'\n\n\n# Database\n\nDATABASES = {}\nDATABASES['default'] = dj_database_url.parse(\n    config(\n        'DEFAULT_DATABASE',\n        default='sqlite:///db.sqlite3'))\n\n\n# Auth\n\nAUTH_USER_MODEL = 'authentication.User'\n\n\n# Password validation\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        'NAME': 'django.contrib.auth.password_validation.' +\n        'UserAttributeSimilarityValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.' +\n        'MinimumLengthValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.' +\n        'CommonPasswordValidator',\n    },\n    {\n        'NAME': 'django.contrib.auth.password_validation.' +\n        'NumericPasswordValidator',\n    },\n]\n\n\n# Internationalization\n\nLANGUAGE_CODE = config('LANGUAGE_CODE', default='en-us')\n\nTIME_ZONE = config('TIME_ZONE', default='UTC')\n\nUSE_I18N = True\n\nUSE_L10N = True\n\nUSE_TZ = True\n\n\n# Static files (CSS, JavaScript, Images)\n\nSTATIC_URL = '/static/'\n\nSTATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')\n\nSTATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'\n\n\n# rest framework\n\nREST_FRAMEWORK = {\n    'DEFAULT_AUTHENTICATION_CLASSES': [\n        'rest_framework.authentication.TokenAuthentication',\n    ],\n    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.' +\n    'LimitOffsetPagination',\n    'PAGE_SIZE': 20,\n    'DEFAULT_FILTER_BACKENDS': [\n        'django_filters.rest_framework.DjangoFilterBackend',\n    ],\n    'DEFAULT_METADATA_CLASS': 'bothub.api.metadata.Metadata',\n}\n\n\n# cors headers\n\nCORS_ORIGIN_ALLOW_ALL = True\nCORS_URLS_REGEX = r'^/api/.*$'\n\n\n# mail\n\nenvvar_EMAIL_HOST = config('EMAIL_HOST', default=None)\n\nADMINS = config(\n    'ADMINS',\n    default='',\n    cast=lambda v: [\n        (\n            s.strip().split('|')[0],\n            s.strip().split('|')[1],\n        ) for s in v.split(',')] if v else [])\nEMAIL_SUBJECT_PREFIX = '[bothub] '\nDEFAULT_FROM_EMAIL = config(\n    'DEFAULT_FROM_EMAIL',\n    default='webmaster@localhost')\nSERVER_EMAIL = config('SERVER_EMAIL', default='root@localhost')\n\nif envvar_EMAIL_HOST:\n    EMAIL_HOST = envvar_EMAIL_HOST\n    EMAIL_PORT = config('EMAIL_PORT', default=25, cast=int)\n    EMAIL_HOST_USER = config('EMAIL_HOST_USER', default='')\n    EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD', default='')\n    EMAIL_USE_SSL = config('EMAIL_USE_SSL', default=False, cast=bool)\n    EMAIL_USE_TLS = config('EMAIL_USE_TLS', default=False, cast=bool)\nelse:\n    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'\n\n\n# webapp\n\nBOTHUB_WEBAPP_BASE_URL = config(\n    'BOTHUB_WEBAPP_BASE_URL',\n    default='http://localhost:8080/')\n\n\n# NLP\n\nBOTHUB_NLP_BASE_URL = config(\n    'BOTHUB_NLP_BASE_URL',\n    default='http://localhost:8001/')\n\n\n# CSRF\n\nCSRF_COOKIE_DOMAIN = config(\n    'CSRF_COOKIE_DOMAIN',\n    default=None)\n\nCSRF_COOKIE_SECURE = config(\n    'CSRF_COOKIE_SECURE',\n    default=False,\n    cast=bool)\n", "path": "bothub/settings.py"}]}