mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-08-21 07:44:13 +00:00
perf: Send report email
This commit is contained in:
parent
ee7c6b4708
commit
c037ce1c29
@ -1604,5 +1604,7 @@
|
||||
"removeWarningMsg": "Are you sure you want to remove",
|
||||
"setVariable": "Set variable",
|
||||
"userId": "User ID",
|
||||
"userName": "User name"
|
||||
"userName": "User name",
|
||||
"ExportAsPDF": "Export as PDF",
|
||||
"EMailReport": "Email Report"
|
||||
}
|
@ -1612,5 +1612,8 @@
|
||||
"removeWarningMsg": "你确定要移除",
|
||||
"setVariable": "设置参数",
|
||||
"userId": "用户ID",
|
||||
"userName": "用户名"
|
||||
"userName": "用户名",
|
||||
"ExportAsPDF": "导出 PDF",
|
||||
"EMailReport": "发送邮件报告",
|
||||
"Print": "打印"
|
||||
}
|
@ -111,11 +111,14 @@ class ExportPdfView(View):
|
||||
|
||||
|
||||
class SendMailView(View):
|
||||
def get(self, request):
|
||||
|
||||
def post(self, request):
|
||||
chart_name = request.GET.get('chart')
|
||||
email = "ibuler@qq.com"
|
||||
if not chart_name or not email:
|
||||
return HttpResponseBadRequest('Missing chart or email parameter')
|
||||
if not chart_name:
|
||||
return HttpResponseBadRequest('Missing chart parameter')
|
||||
email = request.user.email
|
||||
if not email:
|
||||
return HttpResponseBadRequest('Missing email parameter')
|
||||
sessionid = request.COOKIES.get(settings.SESSION_COOKIE_NAME)
|
||||
if not sessionid:
|
||||
return HttpResponseBadRequest('No sessionid found in cookies')
|
||||
@ -138,7 +141,7 @@ class SendMailView(View):
|
||||
|
||||
# 4. 发送邮件
|
||||
subject = f"{title} 报表"
|
||||
from_email = settings.EMAIL_HOST_USER
|
||||
from_email = settings.EMAIL_FROM
|
||||
to = [email]
|
||||
msg = EmailMultiAlternatives(subject, '', from_email, to)
|
||||
msg.attach_alternative(html_content, "text/html")
|
||||
|
Loading…
Reference in New Issue
Block a user