Add mail conf to report error

Brightcells лет %!s(int64=7): %!d(string=назад)
Родитель
Сommit
51e42ffc44
3 измененных файлов с 47 добавлено и 3 удалено
  1. 7 1
      api/urls.py
  2. 7 2
      api/views.py
  3. 33 0
      pai2/settings.py

+ 7 - 1
api/urls.py

@@ -5,6 +5,7 @@ from django_we import views as we_views
5 5
 
6 6
 from account import views as account_views
7 7
 from account import tourguide_views
8
+from api import views as api_views
8 9
 from box import views as box_views
9 10
 from geo import views as geo_views
10 11
 from group import views as group_views
@@ -18,8 +19,13 @@ from photo import views as photo_views
18 19
 from server import server_views
19 20
 
20 21
 
21
-# 帐户相关
22
+# 测试方式:取消注释,请求接口
22 23
 urlpatterns = [
24
+    # url(r'^test$', api_views.mail_error_test, name='mail_error_test'),  # 邮件发送错误信息测试接口
25
+]
26
+
27
+# 帐户相关
28
+urlpatterns += [
23 29
     url(r'^u/wx/authorize$', account_views.user_wx_authorize_api, name='user_wx_authorize_api'),  # 用户端 - 微信用户授权
24 30
 
25 31
     url(r'^u/guest/status$', op_views.guest_api, name='user_guest_status_api'),  # 用户端 - 微游客状态(是否开启)

+ 7 - 2
api/views.py

@@ -1,4 +1,9 @@
1
-from django.shortcuts import render
1
+# -*- coding: utf-8 -*-
2 2
 
3
+from utils.error.response_utils import response
3 4
 
4
-# Create your views here.
5
+
6
+def mail_error_test(request):
7
+    # Raise ZeroDivisionError
8
+    1 / 0
9
+    return response()

+ 33 - 0
pai2/settings.py

@@ -313,6 +313,39 @@ THUMBUP_MESSAGE_AVATAR = PAI2_LOGO_URL
313 313
 LOGIT_BODY_FLAG = True
314 314
 LOGIT_RES_FLAG = True
315 315
 
316
+# 错误信息邮件设置
317
+# Email address that error messages come from.
318
+SERVER_EMAIL = 'kimi@pai.ai'
319
+# The email backend to use. For possible shortcuts see django.core.mail.
320
+# The default is to use the SMTP backend.
321
+# Third-party backends can be specified by providing a Python path
322
+# to a module that defines an EmailBackend class.
323
+EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
324
+# Host for sending email.
325
+EMAIL_HOST = 'smtp.exmail.qq.com'
326
+# Port for sending email.
327
+EMAIL_PORT = 25
328
+# Optional SMTP authentication information for EMAIL_HOST.
329
+EMAIL_HOST_USER = 'kimi@pai.ai'
330
+EMAIL_HOST_PASSWORD = '<^_^>pwd<^_^>'
331
+EMAIL_USE_TLS = False
332
+EMAIL_USE_SSL = False
333
+EMAIL_SSL_CERTFILE = None
334
+EMAIL_SSL_KEYFILE = None
335
+EMAIL_TIMEOUT = None
336
+# Default email address to use for various automated correspondence from
337
+# the site managers.
338
+DEFAULT_FROM_EMAIL = 'Kimi <kimi@pai.ai>'
339
+# People who get code error notifications.
340
+# In the format [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')]
341
+ADMINS = [('Kimi', 'kimi@pai.ai')]
342
+# Not-necessarily-technical managers of the site. They get broken link
343
+# notifications and other various emails.
344
+MANAGERS = ADMINS
345
+# Subject-line prefix for email messages send with django.core.mail.mail_admins
346
+# or ...mail_managers.  Make sure to include the trailing space.
347
+EMAIL_SUBJECT_PREFIX = u'[Pai2] '
348
+
316 349
 try:
317 350
     from local_settings import *
318 351
 except ImportError: