Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
c9ca81e8
Commit
c9ca81e8
authored
Oct 08, 2019
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 邮件设置添加测试邮件收件人配置项
parent
90ec6a29
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
2 deletions
+10
-2
settings.py
apps/jumpserver/settings.py
+1
-0
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+0
-0
api.py
apps/settings/api.py
+4
-2
forms.py
apps/settings/forms.py
+4
-0
serializers.py
apps/settings/serializers.py
+1
-0
No files found.
apps/jumpserver/settings.py
View file @
c9ca81e8
...
...
@@ -357,6 +357,7 @@ EMAIL_PORT = 25
EMAIL_HOST_USER
=
'noreply@jumpserver.org'
EMAIL_HOST_PASSWORD
=
''
EMAIL_FROM
=
''
EMAIL_RECIPIENT
=
''
EMAIL_USE_SSL
=
False
EMAIL_USE_TLS
=
False
EMAIL_SUBJECT_PREFIX
=
'[JMS] '
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
c9ca81e8
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
c9ca81e8
This diff is collapsed.
Click to expand it.
apps/settings/api.py
View file @
c9ca81e8
...
...
@@ -30,6 +30,7 @@ class MailTestingAPI(APIView):
serializer
=
self
.
serializer_class
(
data
=
request
.
data
)
if
serializer
.
is_valid
():
email_from
=
serializer
.
validated_data
[
"EMAIL_FROM"
]
email_recipient
=
serializer
.
validated_data
[
"EMAIL_RECIPIENT"
]
email_host_user
=
serializer
.
validated_data
[
"EMAIL_HOST_USER"
]
for
k
,
v
in
serializer
.
validated_data
.
items
():
if
k
.
startswith
(
'EMAIL'
):
...
...
@@ -38,11 +39,12 @@ class MailTestingAPI(APIView):
subject
=
"Test"
message
=
"Test smtp setting"
email_from
=
email_from
or
email_host_user
send_mail
(
subject
,
message
,
email_from
,
[
email_from
])
email_recipient
=
email_recipient
or
email_from
send_mail
(
subject
,
message
,
email_from
,
[
email_recipient
])
except
Exception
as
e
:
return
Response
({
"error"
:
str
(
e
)},
status
=
401
)
return
Response
({
"msg"
:
self
.
success_message
.
format
(
email_
host_user
)})
return
Response
({
"msg"
:
self
.
success_message
.
format
(
email_
recipient
)})
else
:
return
Response
({
"error"
:
str
(
serializer
.
errors
)},
status
=
401
)
...
...
apps/settings/forms.py
View file @
c9ca81e8
...
...
@@ -89,6 +89,10 @@ class EmailSettingForm(BaseForm):
"Tips: Send mail account, default SMTP account as the send account"
)
)
EMAIL_RECIPIENT
=
forms
.
CharField
(
max_length
=
128
,
label
=
_
(
"Test recipient"
),
initial
=
''
,
required
=
False
,
help_text
=
_
(
"Tips: Used only as a test mail recipient"
)
)
EMAIL_USE_SSL
=
forms
.
BooleanField
(
label
=
_
(
"Use SSL"
),
initial
=
False
,
required
=
False
,
help_text
=
_
(
"If SMTP port is 465, may be select"
)
...
...
apps/settings/serializers.py
View file @
c9ca81e8
...
...
@@ -7,6 +7,7 @@ class MailTestSerializer(serializers.Serializer):
EMAIL_HOST_USER
=
serializers
.
CharField
(
max_length
=
1024
)
EMAIL_HOST_PASSWORD
=
serializers
.
CharField
(
required
=
False
,
allow_blank
=
True
)
EMAIL_FROM
=
serializers
.
CharField
(
required
=
False
,
allow_blank
=
True
)
EMAIL_RECIPIENT
=
serializers
.
CharField
(
required
=
False
,
allow_blank
=
True
)
EMAIL_USE_SSL
=
serializers
.
BooleanField
(
default
=
False
)
EMAIL_USE_TLS
=
serializers
.
BooleanField
(
default
=
False
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment