diff --git a/fe/src/views/ListView.vue b/fe/src/views/ListView.vue index 4ca3dcb..d314635 100644 --- a/fe/src/views/ListView.vue +++ b/fe/src/views/ListView.vue @@ -40,6 +40,14 @@ + + + ! + + + diff --git a/server/config/config.json b/server/config/config.json index 54b48a7..36ad3aa 100644 --- a/server/config/config.json +++ b/server/config/config.json @@ -1,16 +1,17 @@ { - "logLevel": "debug", - "domain": "domain.com", - "webDomain": "mail.domain.com", + "logLevel": "", + "domain": "test.domain", + "domains": null, + "webDomain": "mail.test.domain", "dkimPrivateKeyPath": "config/dkim/dkim.priv", - "sslType": "0", - "SSLPrivateKeyPath": "config/ssl/private.key", - "SSLPublicKeyPath": "config/ssl/public.crt", - "dbDSN": "./config/pmail.db", + "sslType": "1", + "SSLPrivateKeyPath": "./config/ssl/private.key", + "SSLPublicKeyPath": "./config/ssl/public.crt", + "dbDSN": "./config/pmail_temp.db", "dbType": "sqlite", - "spamFilterLevel": 1, + "httpsEnabled": 1, + "spamFilterLevel": 0, "httpPort": 80, "httpsPort": 443, - "isInit": true, - "httpsEnabled": 1 + "isInit": true } \ No newline at end of file diff --git a/server/config/ssl/private.key b/server/config/ssl/private.key index 6e7bf48..6428258 100644 --- a/server/config/ssl/private.key +++ b/server/config/ssl/private.key @@ -1,27 +1,27 @@ -----BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAycVukHU+lPXo01d0W8ok0pxfy8/+tHKqd6gd9g1J6EOpf2SU -vR77+URpKNXxMokVX84VHnBGxDMvh5hM8oN5gqbJEwhTqOwZi19MQVfI5a1wrkYe -p1+hcAS/MsLgwqxFp7ABsH2oljQLLYsGZTs/+QooDcmE2K+Nnj2nM5VZ9ouGX2AN -PFMvSm1yuADmP4962xXEN730UfEamRTGsuU9U1g51cAUasblIf2RU9nKdEQsEihp -ApS45X2qayWgo3YJ6BAaqbZKmnekeIWkjlhHNYudNVxIqvp5MzndMPCNjfz/+xEc -Vn3hS5vzJMZQeOPJjSes6E2Cr0X2cvXnQG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oHGgOu83e1dZiA1GUCgYEA+u8w +mHKbs720lD4HaSllxDRgAejnlmtyOZUm63dKxYAmwMaw0f1Y0UBn88hBNFcVxba2 +CIEuz11MuhPGHh6esricmLryw8IPWzchuSZtxHu6OKggWFoCfGR/TxHqVqSLvSI3 +B+GrdMQ2EqdmhzKgWQCazRtRlSrisRbrF5kkdw8CgYAwz/EJOk5ukUWrpsE0W0dp +UOplU3TAj3yga/aDzphYfJH9M7fgdR9oTNUiD8rvHsW8NgQwZgXL4F2lz7X6tNPR +1A3z/RuhfRURSOoES6xMizaeNb+ZHIORa9a4wHHiE3XMILeTDy7Rb1iuzjlv63lk +KLMNU8pkhCo3DA+iBjeQ8QKBgQCTmKUoxiC3NFpG58VMIcFuCrB97xRo8YIaRJTD +40LjsGEa+sN+gFoBmrSKO7u+oYp45ONlVTbHWcWLnZ3mkXQfA194pl2srzSBHoiD +cwsViwEZ2ipMTYUwzZvkUlFX7SkUck+UHzTOVarIhhZUZ37RWv2yruLprnPwXd6h +3r4IGQKBgQCTeZPaMFsuSzBc1twb6NAxEkPhcZXOAFC+xbGM/jcDx5MZqLAi9gVS +ASuZcWLtLsmIkmzBWnZyFm4enSUhTUYW8qpoV+KDM4RH8yBjSvitrr9lToM7nnnX +eauj/AgwH9D6pt3JtyPeqVOLeCo9LWSQBkKJKxdkPPIDaz4OlgRn3A== -----END RSA PRIVATE KEY----- diff --git a/server/config/ssl/public.crt b/server/config/ssl/public.crt index c2853d9..28db02a 100644 --- a/server/config/ssl/public.crt +++ b/server/config/ssl/public.crt @@ -1,61 +1,22 @@ -----BEGIN CERTIFICATE----- -MIIFFDCCA/ygAwIBAgISBNoMwrAFQkkwJmbpDuLTLHLiMA0GCSqGSIb3DQEBCwUA -MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD -EwJSMzAeFw0yNDA0MTUwNTQ3MzlaFw0yNDA3MTQwNTQ3MzhaMBwxGjAYBgNVBAMT -E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ZOsCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAIl8L +nL+wICckIRTfO4K4+F+7UHgLI2iTYRic6Hsy3K0aPvZAdVJiOlz0qaEcce+bFzj7 +BZiHQWDgiPF4vNFqcmas4oFV+Au2K8AoYQFJrq+3dtiUaMStT7JkjNjci3C2NhPO +U7Gjq2OJx6IrJr7ECr2SFW4Sstw/h+s/mBfNl2BbE7kmT1xu/lyxpIiT7bYgSk/l +A3cJFE1JIoa7eUPpV4Kh0titwJnDYVfQmEeBNYivyeNwe4hiHtiZDamI6H7Wu95b +ldRRiFELoVs0GCn/ttIaSFvGUPeahn9rTNUUkjp4Un0RxuQFx8umQYl50zt1GZ1X +DICmWUwYYejqdXrrww== -----END CERTIFICATE----- diff --git a/server/config/ssl/server.csr b/server/config/ssl/server.csr new file mode 100644 index 0000000..bbe4828 --- /dev/null +++ b/server/config/ssl/server.csr @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIICzjCCAbYCAQAwgYgxCzAJBgNVBAYTAkNOMRMwEQYDVQQIDApTb21lLVN0YXRl +MQswCQYDVQQHDAJCSjEOMAwGA1UECgwFUE1haWwxDjAMBgNVBAsMBVBNYWlsMRYw +FAYDVQQDDA0qLnRlc3QuZG9tYWluMR8wHQYJKoZIhvcNAQkBFhB0ZXN0QHRlc3Qu +ZG9tYWluMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA9uf8Kl44pXTg +JSzns6SvySW4IRXh+K1Vi9FF4NRk3BysM0kIANFU+VmH7eV/Ql1F4Lrwzalset3Q +It5qsBFFDA8me42mF2KYXqIVWvcSg+1MPPMkUpb9jEPJAEOtMVVWKPu7AntCcWcm +NESgSNLXDt7Ok7/hQ93jhiUQzrev6O5jNVvsfiyQncfMuaHi3joRxojFfq454djs +wNy0DGswaN9qF+6uGgBgdwc7vOA81YzVDli33NCjwq/RjYu8fFJSZlWtvgYdCEoO +e9qhknLzQAD3wCzdkkmIKZP/igg8dvhz71L+4NWqDhYe1zmkAXL6Y8CucpiW1FrC +RYjpDXtk6wIDAQABoAAwDQYJKoZIhvcNAQELBQADggEBAPSNiDkAGFhMWFzQns+a +6+ujoI8Lf7baN/LklEEMRV2xq5sonj72ZU4PJDAyNFVj+pCKDOH5mb0r5ceRKYx/ +HOlXxYvDhvk3t9mAGrRwG3UhzbCSbIIcvdKbU4FDGaRIzrSsvcv9fUDnw5fKTL61 +IRDNewABlCncsUYfHrXeuMtqdiWyZMfYjiHDunCCo/FbrG70q9LjMHT4zHl9LV8T +jnrQzX0UaxBgLYDPEJX+2fqaXObv1HHSWlgZ6Ov9eRRKN2oRkb+KIbaTnlQ7Z7Y9 +kzwla/WOKJDL5FA7275tVpC553+rglq/0Jy9Hiq71Sis9gnG8eTYsghN5FHZSMFT +a1s= +-----END CERTIFICATE REQUEST----- diff --git a/server/controllers/email/list.go b/server/controllers/email/list.go index 5b5c7b2..2d66f02 100644 --- a/server/controllers/email/list.go +++ b/server/controllers/email/list.go @@ -27,6 +27,7 @@ type emilItem struct { IsRead bool `json:"is_read"` Sender User `json:"sender"` Dangerous bool `json:"dangerous"` + Error string `json:"error"` } type User struct { @@ -83,6 +84,7 @@ func EmailList(ctx *context.Context, w http.ResponseWriter, req *http.Request) { IsRead: email.IsRead == 1, Sender: sender, Dangerous: email.SPFCheck == 0 && email.DKIMCheck == 0, + Error: email.Error.String, }) } diff --git a/server/controllers/email/send.go b/server/controllers/email/send.go index 8141b8e..14d6ce4 100644 --- a/server/controllers/email/send.go +++ b/server/controllers/email/send.go @@ -213,11 +213,28 @@ func Send(ctx *context.Context, w http.ResponseWriter, req *http.Request) { if err != nil { log.WithContext(ctx).Errorf("sql Error :%+v", err) } + + ue := models.UserEmail{ + UserID: ctx.UserID, + EmailID: modelEmail.Id, + Status: 2, + IsRead: 1, + } + db.Instance.Insert(&ue) + } else { _, err := db.Instance.Exec(db.WithContext(ctx, "update email set status =1 where id = ? "), modelEmail.Id) if err != nil { log.WithContext(ctx).Errorf("sql Error :%+v", err) } + + ue := models.UserEmail{ + UserID: ctx.UserID, + EmailID: modelEmail.Id, + Status: 1, + IsRead: 1, + } + db.Instance.Insert(&ue) } }, nil) diff --git a/server/controllers/group.go b/server/controllers/group.go index 6ef9f81..d798a77 100644 --- a/server/controllers/group.go +++ b/server/controllers/group.go @@ -31,7 +31,7 @@ func GetUserGroup(ctx *context.Context, w http.ResponseWriter, req *http.Request }, { Label: i18n.GetText(ctx.Lang, "outbox"), - Tag: dto.SearchTag{Type: 1, Status: 1}.ToString(), + Tag: dto.SearchTag{Type: 1, Status: -1}.ToString(), }, { Label: i18n.GetText(ctx.Lang, "sketch"), diff --git a/server/main_test.go b/server/main_test.go index 9a43e3f..7267100 100644 --- a/server/main_test.go +++ b/server/main_test.go @@ -735,8 +735,9 @@ func testEmailList(t *testing.T) { t.Error("Get Email List Api Error!") } dt := data.Data.(map[string]interface{}) - if len(dt["list"].([]interface{})) == 0 { + if dt["list"] == nil || len(dt["list"].([]interface{})) == 0 { t.Error("Email List Is Empty!") + return } lst := dt["list"].([]interface{}) diff --git a/server/models/user_email.go b/server/models/user_email.go index e1f5353..5c1c11b 100644 --- a/server/models/user_email.go +++ b/server/models/user_email.go @@ -2,8 +2,8 @@ package models type UserEmail struct { ID int `xorm:"id int unsigned not null pk autoincr"` - UserID int `xorm:"user_id int not null unique('uid_eid') index comment('用户id')"` - EmailID int `xorm:"email_id not null unique('uid_eid') index comment('信件id')"` + UserID int `xorm:"user_id int not null index('idx_eid') index comment('用户id')"` + EmailID int `xorm:"email_id not null index('idx_eid') index comment('信件id')"` IsRead int8 `xorm:"is_read tinyint(1) comment('是否已读')" json:"is_read"` GroupId int `xorm:"group_id int notnull default(0) comment('分组id')'" json:"group_id"` Status int8 `xorm:"status tinyint(4) notnull default(0) comment('0未发送,1已发送,2发送失败,3删除')" json:"status"` // 0未发送,1已发送,2发送失败 3删除 diff --git a/server/services/detail/detail.go b/server/services/detail/detail.go index f3098ea..a6b598b 100644 --- a/server/services/detail/detail.go +++ b/server/services/detail/detail.go @@ -37,7 +37,7 @@ func GetEmailDetail(ctx *context.Context, id int, markRead bool) (*response.Emai if markRead && ue.IsRead == 0 { ue.IsRead = 1 - _, err = db.Instance.Update(&ue) + _, err = db.Instance.Where("id=?", ue.ID).Update(&ue) if err != nil { log.WithContext(ctx).Errorf("SQL error:%+v", err) } diff --git a/server/utils/send/send.go b/server/utils/send/send.go index ee156d0..82ed62c 100644 --- a/server/utils/send/send.go +++ b/server/utils/send/send.go @@ -76,24 +76,28 @@ func Forward(ctx *context.Context, e *parsemail.Email, forwardAddress string) er tos := tos as.WaitProcess(func(p any) { err := smtp.SendMail("", domain.mxHost+":25", nil, e.From.EmailAddress, buildAddress(tos), b) - if err != nil { - log.WithContext(ctx).Warnf("SMTP Send Error! Error:%+v", err) - } else { - log.WithContext(ctx).Infof("SMTP Send Success !") - } - // 重新选取证书域名 + // 使用其他方式发送 if err != nil { + // EOF 表示未知错误,此时降级为非tls连接发送(目前仅139邮箱有这个问题) + if errors.Is(err, smtp.NoSupportSTARTTLSError) || err.Error() == "EOF" { + err = smtp.SendMailWithTls("", domain.mxHost+":465", nil, e.From.EmailAddress, buildAddress(tos), b) + if err != nil { + log.WithContext(ctx).Warnf("Unsafe! %s Server Not Support SMTPS & STARTTLS", domain.domain) + err = smtp.SendMailUnsafe("", domain.mxHost+":25", nil, e.From.EmailAddress, buildAddress(tos), b) + } + } + + // 证书错误,从新选取证书发送 if certificateErr, ok := err.(*tls.CertificateVerificationError); ok { - if hostnameErr, is := certificateErr.Err.(x509.HostnameError); is { + // 单测使用 + if domain.domain == "localhost" { + err = smtp.SendMailUnsafe("", domain.mxHost+":25", nil, e.From.EmailAddress, buildAddress(tos), b) + } else if hostnameErr, is := certificateErr.Err.(x509.HostnameError); is { if hostnameErr.Certificate != nil { certificateHostName := hostnameErr.Certificate.DNSNames + // 重新选取证书发送 err = smtp.SendMail(domainMatch(domain.domain, certificateHostName), domain.mxHost+":25", nil, e.From.EmailAddress, buildAddress(tos), b) - if err != nil { - log.WithContext(ctx).Warnf("SMTP Send Error! Error:%+v", err) - } else { - log.WithContext(ctx).Infof("SMTP Send Success !") - } } } } @@ -185,7 +189,10 @@ func Send(ctx *context.Context, e *parsemail.Email) (error, map[string]error) { // 证书错误,从新选取证书发送 if certificateErr, ok := err.(*tls.CertificateVerificationError); ok { - if hostnameErr, is := certificateErr.Err.(x509.HostnameError); is { + // 单测使用 + if domain.domain == "localhost" { + err = smtp.SendMailUnsafe("", domain.mxHost+":25", nil, e.From.EmailAddress, buildAddress(tos), b) + } else if hostnameErr, is := certificateErr.Err.(x509.HostnameError); is { if hostnameErr.Certificate != nil { certificateHostName := hostnameErr.Certificate.DNSNames // 重新选取证书发送