Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
41a2619e
authored
Mar 28, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: able to set smtp ssl
parent
ce7cbccf
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
2 deletions
+16
-2
common/constants.go
+1
-0
common/email.go
+1
-1
model/option.go
+3
-0
web/src/components/SystemSetting.js
+11
-1
No files found.
common/constants.go
View file @
41a2619e
...
...
@@ -75,6 +75,7 @@ var LogConsumeEnabled = true
var
SMTPServer
=
""
var
SMTPPort
=
587
var
SMTPSSLEnabled
=
false
var
SMTPAccount
=
""
var
SMTPFrom
=
""
var
SMTPToken
=
""
...
...
common/email.go
View file @
41a2619e
...
...
@@ -24,7 +24,7 @@ func SendEmail(subject string, receiver string, content string) error {
addr
:=
fmt
.
Sprintf
(
"%s:%d"
,
SMTPServer
,
SMTPPort
)
to
:=
strings
.
Split
(
receiver
,
";"
)
var
err
error
if
SMTPPort
==
465
{
if
SMTPPort
==
465
||
SMTPSSLEnabled
{
tlsConfig
:=
&
tls
.
Config
{
InsecureSkipVerify
:
true
,
ServerName
:
SMTPServer
,
...
...
model/option.go
View file @
41a2619e
...
...
@@ -50,6 +50,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"SMTPPort"
]
=
strconv
.
Itoa
(
common
.
SMTPPort
)
common
.
OptionMap
[
"SMTPAccount"
]
=
""
common
.
OptionMap
[
"SMTPToken"
]
=
""
common
.
OptionMap
[
"SMTPSSLEnabled"
]
=
strconv
.
FormatBool
(
common
.
SMTPSSLEnabled
)
common
.
OptionMap
[
"Notice"
]
=
""
common
.
OptionMap
[
"About"
]
=
""
common
.
OptionMap
[
"HomePageContent"
]
=
""
...
...
@@ -199,6 +200,8 @@ func updateOptionMap(key string, value string) (err error) {
constant
.
CheckSensitiveOnCompletionEnabled
=
boolValue
case
"StopOnSensitiveEnabled"
:
constant
.
StopOnSensitiveEnabled
=
boolValue
case
"SMTPSSLEnabled"
:
common
.
SMTPSSLEnabled
=
boolValue
}
}
switch
key
{
...
...
web/src/components/SystemSetting.js
View file @
41a2619e
...
...
@@ -42,6 +42,7 @@ const SystemSetting = () => {
TurnstileSecretKey
:
''
,
RegisterEnabled
:
''
,
EmailDomainRestrictionEnabled
:
''
,
SMTPSSLEnabled
:
''
,
EmailDomainWhitelist
:
[],
// telegram login
TelegramOAuthEnabled
:
''
,
...
...
@@ -98,6 +99,7 @@ const SystemSetting = () => {
case
'TelegramOAuthEnabled'
:
case
'TurnstileCheckEnabled'
:
case
'EmailDomainRestrictionEnabled'
:
case
'SMTPSSLEnabled'
:
case
'RegisterEnabled'
:
value
=
inputs
[
key
]
===
'true'
?
'false'
:
'true'
;
break
;
...
...
@@ -134,7 +136,7 @@ const SystemSetting = () => {
}
if
(
name
===
'Notice'
||
name
.
startsWith
(
'SMTP
'
)
||
(
name
.
startsWith
(
'SMTP'
)
&&
name
!==
'SMTPSSLEnabled
'
)
||
name
===
'ServerAddress'
||
name
===
'EpayId'
||
name
===
'EpayKey'
||
...
...
@@ -570,6 +572,14 @@ const SystemSetting = () => {
placeholder
=
'敏感信息不会发送到前端显示'
/>
<
/Form.Group
>
<
Form
.
Group
widths
=
{
3
}
>
<
Form
.
Checkbox
label
=
'启用SMTP SSL(465端口强制开启)'
name
=
'SMTPSSLEnabled'
onChange
=
{
handleInputChange
}
checked
=
{
inputs
.
SMTPSSLEnabled
===
'true'
}
/
>
<
/Form.Group
>
<
Form
.
Button
onClick
=
{
submitSMTP
}
>
保存
SMTP
设置
<
/Form.Button
>
<
Divider
/>
<
Header
as
=
'h3'
>
...
...
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