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
7715e62d
Unverified
Commit
7715e62d
authored
Jun 14, 2019
by
BaiJiangJie
Committed by
GitHub
Jun 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 邮件设置添加配置项:发送账号 (#2796)
parent
5286bf3a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
3 deletions
+15
-3
tasks.py
apps/common/tasks.py
+2
-1
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
+3
-1
forms.py
apps/settings/forms.py
+8
-1
serializers.py
apps/settings/serializers.py
+1
-0
No files found.
apps/common/tasks.py
View file @
7715e62d
...
...
@@ -24,7 +24,8 @@ def send_mail_async(*args, **kwargs):
if
len
(
args
)
==
3
:
args
=
list
(
args
)
args
[
0
]
=
settings
.
EMAIL_SUBJECT_PREFIX
+
args
[
0
]
args
.
insert
(
2
,
settings
.
EMAIL_HOST_USER
)
email_from
=
settings
.
EMAIL_FROM
or
settings
.
EMAIL_HOST_USER
args
.
insert
(
2
,
email_from
)
args
=
tuple
(
args
)
try
:
...
...
apps/jumpserver/settings.py
View file @
7715e62d
...
...
@@ -353,6 +353,7 @@ EMAIL_HOST = 'smtp.jumpserver.org'
EMAIL_PORT
=
25
EMAIL_HOST_USER
=
'noreply@jumpserver.org'
EMAIL_HOST_PASSWORD
=
''
EMAIL_FROM
=
''
EMAIL_USE_SSL
=
False
EMAIL_USE_TLS
=
False
EMAIL_SUBJECT_PREFIX
=
'[JMS] '
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
7715e62d
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
7715e62d
This diff is collapsed.
Click to expand it.
apps/settings/api.py
View file @
7715e62d
...
...
@@ -30,6 +30,7 @@ class MailTestingAPI(APIView):
def
post
(
self
,
request
):
serializer
=
self
.
serializer_class
(
data
=
request
.
data
)
if
serializer
.
is_valid
():
email_from
=
serializer
.
validated_data
[
"EMAIL_FROM"
]
email_host_user
=
serializer
.
validated_data
[
"EMAIL_HOST_USER"
]
for
k
,
v
in
serializer
.
validated_data
.
items
():
if
k
.
startswith
(
'EMAIL'
):
...
...
@@ -37,7 +38,8 @@ class MailTestingAPI(APIView):
try
:
subject
=
"Test"
message
=
"Test smtp setting"
send_mail
(
subject
,
message
,
email_host_user
,
[
email_host_user
])
email_from
=
email_from
or
email_host_user
send_mail
(
subject
,
message
,
email_from
,
[
email_host_user
])
except
Exception
as
e
:
return
Response
({
"error"
:
str
(
e
)},
status
=
401
)
...
...
apps/settings/forms.py
View file @
7715e62d
...
...
@@ -80,7 +80,14 @@ class EmailSettingForm(BaseForm):
)
EMAIL_HOST_PASSWORD
=
FormEncryptCharField
(
max_length
=
1024
,
label
=
_
(
"SMTP password"
),
widget
=
forms
.
PasswordInput
,
required
=
False
,
help_text
=
_
(
"Some provider use token except password"
)
required
=
False
,
help_text
=
_
(
"Tips: Some provider use token except password"
)
)
EMAIL_FROM
=
forms
.
CharField
(
max_length
=
128
,
label
=
_
(
"Send user"
),
initial
=
''
,
required
=
False
,
help_text
=
_
(
"Tips: Send mail account, default SMTP account as the send account"
)
)
EMAIL_USE_SSL
=
forms
.
BooleanField
(
label
=
_
(
"Use SSL"
),
initial
=
False
,
required
=
False
,
...
...
apps/settings/serializers.py
View file @
7715e62d
...
...
@@ -6,6 +6,7 @@ class MailTestSerializer(serializers.Serializer):
EMAIL_PORT
=
serializers
.
IntegerField
(
default
=
25
)
EMAIL_HOST_USER
=
serializers
.
CharField
(
max_length
=
1024
)
EMAIL_HOST_PASSWORD
=
serializers
.
CharField
()
EMAIL_FROM
=
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