|
Thanks, SERVER_EMAIL is essential to this problem , I've written a article 
about the problem, learn more 
|
http://redstoneleo.blogspot.com/2016/12/email-reporting-exceptions-and-errors_30.html





在 2016-12-29 16:20:17,"Luis Zárate" <luisz...@gmail.com> 写道:

try to change de django loggin

https://docs.djangoproject.com/en/1.10/topics/logging/#examples



2016-12-28 9:45 GMT-06:00 Philip Lee <redstone-c...@163.com>:

Please help! The question are also posted here
http://stackoverflow.com/questions/41363888/django-doesnt-email-reporting-an-internal-server-error-http-status-code-500




I could send mail using the following code

E:\Python\django-test\LYYDownloaderServer>python manage.py shell

Python3.5.2(v3.5.2:4def2a2901a5,Jun252016,22:01:18)[MSC v.190032 bit (In
tel)] on win32
Type"help","copyright","credits"or"license"for more 
information.(InteractiveConsole)>>>from django.core.mail import send_mail
>>>>>> send_mail(...'Subject here',...'Here is the 
>>>>>> message.',...'redstone-c...@163.com',...['2281570...@qq.com'],...     
>>>>>> fail_silently=False,...)1>>>

According to the doc:

When DEBUG is False, Django will email the users listed in the ADMINS setting 
whenever your code raises an unhandled exception and results in an internal 
server error (HTTP status code 500). This gives the administrators immediate 
notification of any errors. The ADMINS will get a description of the error, a 
complete Python traceback, and details about the HTTP request that caused the 
error.

but in my case, Django doesn't email reporting an internal server error (HTTP 
status code 500) 

what's the problem? please help fix the problem




settings.py

"""
Django settings for LYYDownloaderServer project.

Generated by 'django-admin startproject' using Django 1.9.1.

For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""import os
ADMINS =[('Philip','r234327...@163.com'),('Philip2','768799...@qq.com')]
EMAIL_HOST ='smtp.163.com'# 'localhost'#'smtp.139.com'# EMAIL_PORT = 25# 
EMAIL_USE_TLS = True

EMAIL_HOST_USER ='r234327...@163.com'# '13529123...@139.com'
EMAIL_HOST_PASSWORD ='******'# DEFAULT_FROM_EMAIL = 'r234327...@163.com'# Build 
paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))# 
Quick-start development settings - unsuitable for production# See 
https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/# SECURITY 
WARNING: keep the secret key used in production secret!
SECRET_KEY ='s4(z8qzt$=x(2t(ok5bb58_!u==+x97t0vpa=*8bb_68baekkh'# SECURITY 
WARNING: don't run with debug turned on in production!
DEBUG =False

ALLOWED_HOSTS =['127.0.0.1']#,'.0letter.com'# Application definition

INSTALLED_APPS 
=['VideoParser.apps.VideoparserConfig','FileHost.apps.FilehostConfig','django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles',]

MIDDLEWARE_CLASSES 
=['django.middleware.common.BrokenLinkEmailsMiddleware','django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.auth.middleware.SessionAuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',]

ROOT_URLCONF ='LYYDownloaderServer.urls'

TEMPLATES 
=[{'BACKEND':'django.template.backends.django.DjangoTemplates','DIRS':[],'APP_DIRS':True,'OPTIONS':{'context_processors':['django.template.context_processors.debug','django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages',],},},]

WSGI_APPLICATION ='LYYDownloaderServer.wsgi.application'# Database# 
https://docs.djangoproject.com/en/1.9/ref/settings/#databases

DATABASES ={'default':{'ENGINE':'django.db.backends.sqlite3','NAME': 
os.path.join(BASE_DIR,'db.sqlite3'),}}# Password validation# 
https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS 
=[{'NAME':'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',},{'NAME':'django.contrib.auth.password_validation.MinimumLengthValidator',},{'NAME':'django.contrib.auth.password_validation.CommonPasswordValidator',},{'NAME':'django.contrib.auth.password_validation.NumericPasswordValidator',},]#
 Internationalization# https://docs.djangoproject.com/en/1.9/topics/i18n/

LANGUAGE_CODE ='en-us'

TIME_ZONE ='UTC'

USE_I18N =True

USE_L10N =True

USE_TZ =True# Static files (CSS, JavaScript, Images)# 
https://docs.djangoproject.com/en/1.9/howto/static-files/

STATIC_URL ='/static/'

the start of views.py

from django.http importJsonResponse,HttpResponseimport logging
import m3u8
import os
fromVideoParser.parsers.CommonParsersimport*import urllib.parse
import hashlib
from datetime import datetime, timedelta, date
from django.views.decorators.csrf import csrf_exempt
from django.db importIntegrityErrorfromVideoParser.models import*from importlib 
import import_module
# print('-------------views --------')
FILES_DIR ='files'# specialHostName2module = {'56': 'v56'}
logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d %I:%M:%S 
%p', level=logging.ERROR, 
handlers=[logging.handlers.RotatingFileHandler(filename=os.path.join(FILES_DIR,'LYYDownloaderServer.log'),
 maxBytes=1024*1024, backupCount=1)])...

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4e6cbea4-c415-4243-aafe-7457a22a8f10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




--

"La utopía sirve para caminar" Fernando Birri




--
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/AygamXvx6ho/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyN3PaXQQ-NsCG6SB%2B%2BCPxOQYjNZFyzCz9cts%2BrF%2BmL-DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1b38bf39.fc24.1594f7a2182.Coremail.redstone-cold%40163.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to