mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-21 17:56:38 +08:00
feat: able to set smtp ssl
This commit is contained in:
parent
786ccc7da0
commit
5c39f54040
@ -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 = ""
|
||||||
|
@ -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,
|
||||||
|
@ -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) {
|
|||||||
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 {
|
||||||
|
@ -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 = () => {
|
|||||||
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 = () => {
|
|||||||
}
|
}
|
||||||
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 = () => {
|
|||||||
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'>
|
||||||
|
Loading…
Reference in New Issue
Block a user