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
Hide 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
...
@@ -75,6 +75,7 @@ var LogConsumeEnabled = true
var
SMTPServer
=
""
var
SMTPServer
=
""
var
SMTPPort
=
587
var
SMTPPort
=
587
var
SMTPSSLEnabled
=
false
var
SMTPAccount
=
""
var
SMTPAccount
=
""
var
SMTPFrom
=
""
var
SMTPFrom
=
""
var
SMTPToken
=
""
var
SMTPToken
=
""
...
...
common/email.go
View file @
41a2619e
...
@@ -24,7 +24,7 @@ func SendEmail(subject string, receiver string, content string) error {
...
@@ -24,7 +24,7 @@ func SendEmail(subject string, receiver string, content string) error {
addr
:=
fmt
.
Sprintf
(
"%s:%d"
,
SMTPServer
,
SMTPPort
)
addr
:=
fmt
.
Sprintf
(
"%s:%d"
,
SMTPServer
,
SMTPPort
)
to
:=
strings
.
Split
(
receiver
,
";"
)
to
:=
strings
.
Split
(
receiver
,
";"
)
var
err
error
var
err
error
if
SMTPPort
==
465
{
if
SMTPPort
==
465
||
SMTPSSLEnabled
{
tlsConfig
:=
&
tls
.
Config
{
tlsConfig
:=
&
tls
.
Config
{
InsecureSkipVerify
:
true
,
InsecureSkipVerify
:
true
,
ServerName
:
SMTPServer
,
ServerName
:
SMTPServer
,
...
...
model/option.go
View file @
41a2619e
...
@@ -50,6 +50,7 @@ func InitOptionMap() {
...
@@ -50,6 +50,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"SMTPPort"
]
=
strconv
.
Itoa
(
common
.
SMTPPort
)
common
.
OptionMap
[
"SMTPPort"
]
=
strconv
.
Itoa
(
common
.
SMTPPort
)
common
.
OptionMap
[
"SMTPAccount"
]
=
""
common
.
OptionMap
[
"SMTPAccount"
]
=
""
common
.
OptionMap
[
"SMTPToken"
]
=
""
common
.
OptionMap
[
"SMTPToken"
]
=
""
common
.
OptionMap
[
"SMTPSSLEnabled"
]
=
strconv
.
FormatBool
(
common
.
SMTPSSLEnabled
)
common
.
OptionMap
[
"Notice"
]
=
""
common
.
OptionMap
[
"Notice"
]
=
""
common
.
OptionMap
[
"About"
]
=
""
common
.
OptionMap
[
"About"
]
=
""
common
.
OptionMap
[
"HomePageContent"
]
=
""
common
.
OptionMap
[
"HomePageContent"
]
=
""
...
@@ -199,6 +200,8 @@ func updateOptionMap(key string, value string) (err error) {
...
@@ -199,6 +200,8 @@ func updateOptionMap(key string, value string) (err error) {
constant
.
CheckSensitiveOnCompletionEnabled
=
boolValue
constant
.
CheckSensitiveOnCompletionEnabled
=
boolValue
case
"StopOnSensitiveEnabled"
:
case
"StopOnSensitiveEnabled"
:
constant
.
StopOnSensitiveEnabled
=
boolValue
constant
.
StopOnSensitiveEnabled
=
boolValue
case
"SMTPSSLEnabled"
:
common
.
SMTPSSLEnabled
=
boolValue
}
}
}
}
switch
key
{
switch
key
{
...
...
web/src/components/SystemSetting.js
View file @
41a2619e
...
@@ -42,6 +42,7 @@ const SystemSetting = () => {
...
@@ -42,6 +42,7 @@ const SystemSetting = () => {
TurnstileSecretKey
:
''
,
TurnstileSecretKey
:
''
,
RegisterEnabled
:
''
,
RegisterEnabled
:
''
,
EmailDomainRestrictionEnabled
:
''
,
EmailDomainRestrictionEnabled
:
''
,
SMTPSSLEnabled
:
''
,
EmailDomainWhitelist
:
[],
EmailDomainWhitelist
:
[],
// telegram login
// telegram login
TelegramOAuthEnabled
:
''
,
TelegramOAuthEnabled
:
''
,
...
@@ -98,6 +99,7 @@ const SystemSetting = () => {
...
@@ -98,6 +99,7 @@ const SystemSetting = () => {
case
'TelegramOAuthEnabled'
:
case
'TelegramOAuthEnabled'
:
case
'TurnstileCheckEnabled'
:
case
'TurnstileCheckEnabled'
:
case
'EmailDomainRestrictionEnabled'
:
case
'EmailDomainRestrictionEnabled'
:
case
'SMTPSSLEnabled'
:
case
'RegisterEnabled'
:
case
'RegisterEnabled'
:
value
=
inputs
[
key
]
===
'true'
?
'false'
:
'true'
;
value
=
inputs
[
key
]
===
'true'
?
'false'
:
'true'
;
break
;
break
;
...
@@ -134,7 +136,7 @@ const SystemSetting = () => {
...
@@ -134,7 +136,7 @@ const SystemSetting = () => {
}
}
if
(
if
(
name
===
'Notice'
||
name
===
'Notice'
||
name
.
startsWith
(
'SMTP
'
)
||
(
name
.
startsWith
(
'SMTP'
)
&&
name
!==
'SMTPSSLEnabled
'
)
||
name
===
'ServerAddress'
||
name
===
'ServerAddress'
||
name
===
'EpayId'
||
name
===
'EpayId'
||
name
===
'EpayKey'
||
name
===
'EpayKey'
||
...
@@ -570,6 +572,14 @@ const SystemSetting = () => {
...
@@ -570,6 +572,14 @@ const SystemSetting = () => {
placeholder
=
'敏感信息不会发送到前端显示'
placeholder
=
'敏感信息不会发送到前端显示'
/>
/>
<
/Form.Group
>
<
/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
>
<
Form
.
Button
onClick
=
{
submitSMTP
}
>
保存
SMTP
设置
<
/Form.Button
>
<
Divider
/>
<
Divider
/>
<
Header
as
=
'h3'
>
<
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