Feat: mail SMTP settings

This commit is contained in:
HFO4
2020-02-23 18:40:14 +08:00
parent ef42ec3927
commit 000a48ff06
7 changed files with 50 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ import (
model "github.com/HFO4/cloudreve/models"
"github.com/HFO4/cloudreve/pkg/cache"
"github.com/HFO4/cloudreve/pkg/conf"
"github.com/HFO4/cloudreve/pkg/email"
"github.com/HFO4/cloudreve/pkg/serializer"
"time"
)
@@ -28,6 +29,19 @@ type BatchSettingGet struct {
Keys []string `json:"keys"`
}
// MailTestService 邮件测试服务
type MailTestService struct {
Email string `json:"to" binding:"email"`
}
// Send 发送测试邮件
func (service *MailTestService) Send() serializer.Response {
if err := email.Send(service.Email, "Cloudreve发信测试", "这是一封测试邮件,用于测试 Cloudreve 发信设置。"); err != nil {
return serializer.Err(serializer.CodeInternalSetting, "发信失败, "+err.Error(), nil)
}
return serializer.Response{}
}
// Get 获取设定值
func (service *BatchSettingGet) Get() serializer.Response {
options := model.GetSettingByNames(service.Keys...)