v2.6.1 (#169)
1、新增垃圾邮件过滤插件 2、使用使用github.com/dlclark/regexp2替换go原生的正则包 3、修复空数据导致的邮件插入失败
This commit is contained in:
1 parent
9ffbdf41c3
commit
054336fe9e
78 files changed
+1123
-329
No files matched your search
@@ -2,11 +2,11 @@ package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/services/attachments"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
"github.com/spf13/cast"
|
||||
"net/http"
|
||||
"pmail/dto/response"
|
||||
"pmail/services/attachments"
|
||||
"pmail/utils/context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
"net/http"
|
||||
"pmail/utils/context"
|
||||
)
|
||||
|
||||
type HandlerFunc func(*context.Context, http.ResponseWriter, *http.Request)
|
||||
@@ -2,12 +2,12 @@ package email
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/services/del_email"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
"pmail/dto/response"
|
||||
"pmail/services/del_email"
|
||||
"pmail/utils/context"
|
||||
)
|
||||
|
||||
type emailDeleteRequest struct {
|
||||
|
||||
@@ -2,12 +2,12 @@ package email
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/services/detail"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
"pmail/dto/response"
|
||||
"pmail/services/detail"
|
||||
"pmail/utils/context"
|
||||
)
|
||||
|
||||
type emailDetailRequest struct {
|
||||
|
||||
@@ -2,15 +2,15 @@ package email
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/dto"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/services/list"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
"io"
|
||||
"math"
|
||||
"net/http"
|
||||
"pmail/dto"
|
||||
"pmail/dto/response"
|
||||
"pmail/services/list"
|
||||
"pmail/utils/context"
|
||||
)
|
||||
|
||||
type emailListResponse struct {
|
||||
|
||||
@@ -2,12 +2,12 @@ package email
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/services/group"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
"pmail/dto/response"
|
||||
"pmail/services/group"
|
||||
"pmail/utils/context"
|
||||
)
|
||||
|
||||
type moveRequest struct {
|
||||
|
||||
@@ -2,12 +2,12 @@ package email
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/services/detail"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
"pmail/dto/response"
|
||||
"pmail/services/detail"
|
||||
"pmail/utils/context"
|
||||
)
|
||||
|
||||
type markReadRequest struct {
|
||||
|
||||
@@ -4,22 +4,22 @@ import (
|
||||
"database/sql"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/config"
|
||||
"github.com/Jinnrry/pmail/db"
|
||||
"github.com/Jinnrry/pmail/dto/parsemail"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/hooks"
|
||||
"github.com/Jinnrry/pmail/hooks/framework"
|
||||
"github.com/Jinnrry/pmail/i18n"
|
||||
"github.com/Jinnrry/pmail/models"
|
||||
"github.com/Jinnrry/pmail/utils/array"
|
||||
"github.com/Jinnrry/pmail/utils/async"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
"github.com/Jinnrry/pmail/utils/send"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
"io"
|
||||
"net/http"
|
||||
"pmail/config"
|
||||
"pmail/db"
|
||||
"pmail/dto/parsemail"
|
||||
"pmail/dto/response"
|
||||
"pmail/hooks"
|
||||
"pmail/hooks/framework"
|
||||
"pmail/i18n"
|
||||
"pmail/models"
|
||||
"pmail/utils/array"
|
||||
"pmail/utils/async"
|
||||
"pmail/utils/context"
|
||||
"pmail/utils/send"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -168,30 +168,31 @@ func Send(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
|
||||
log.WithContext(ctx).Debugf("插件执行--SendBefore End")
|
||||
|
||||
modelEmail := models.Email{
|
||||
Type: 1,
|
||||
Subject: e.Subject,
|
||||
ReplyTo: json2string(e.ReplyTo),
|
||||
FromName: e.From.Name,
|
||||
FromAddress: e.From.EmailAddress,
|
||||
To: json2string(e.To),
|
||||
Bcc: json2string(e.Bcc),
|
||||
Cc: json2string(e.Cc),
|
||||
Text: sql.NullString{String: string(e.Text), Valid: true},
|
||||
Html: sql.NullString{String: string(e.HTML), Valid: true},
|
||||
Sender: json2string(e.Sender),
|
||||
Attachments: json2string(e.Attachments),
|
||||
SPFCheck: 1,
|
||||
DKIMCheck: 1,
|
||||
SendUserID: ctx.UserID,
|
||||
SendDate: time.Now(),
|
||||
Status: 1,
|
||||
CreateTime: time.Now(),
|
||||
Type: 1,
|
||||
Subject: e.Subject,
|
||||
ReplyTo: json2string(e.ReplyTo),
|
||||
FromName: e.From.Name,
|
||||
FromAddress: e.From.EmailAddress,
|
||||
To: json2string(e.To),
|
||||
Bcc: json2string(e.Bcc),
|
||||
Cc: json2string(e.Cc),
|
||||
Text: sql.NullString{String: string(e.Text), Valid: true},
|
||||
Html: sql.NullString{String: string(e.HTML), Valid: true},
|
||||
Sender: json2string(e.Sender),
|
||||
Attachments: json2string(e.Attachments),
|
||||
SPFCheck: 1,
|
||||
DKIMCheck: 1,
|
||||
SendUserID: ctx.UserID,
|
||||
SendDate: time.Now(),
|
||||
CronSendTime: time.Now(),
|
||||
Status: 1,
|
||||
CreateTime: time.Now(),
|
||||
}
|
||||
|
||||
_, err = db.Instance.Insert(&modelEmail)
|
||||
|
||||
if err != nil || modelEmail.Id <= 0 {
|
||||
log.Println("mysql insert error:", err.Error())
|
||||
log.Println("insert error:", err.Error())
|
||||
response.NewErrorResponse(response.ServerError, i18n.GetText(ctx.Lang, "send_fail"), err.Error()).FPrint(w)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/db"
|
||||
"github.com/Jinnrry/pmail/dto"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/i18n"
|
||||
"github.com/Jinnrry/pmail/models"
|
||||
"github.com/Jinnrry/pmail/services/group"
|
||||
"github.com/Jinnrry/pmail/utils/array"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
"pmail/db"
|
||||
"pmail/dto"
|
||||
"pmail/dto/response"
|
||||
"pmail/i18n"
|
||||
"pmail/models"
|
||||
"pmail/services/group"
|
||||
"pmail/utils/array"
|
||||
"pmail/utils/context"
|
||||
)
|
||||
|
||||
func GetUserGroupList(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/Jinnrry/pmail/config"
|
||||
"net/http"
|
||||
"pmail/config"
|
||||
)
|
||||
|
||||
func Interceptor(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
+10
-10
@@ -3,19 +3,19 @@ package controllers
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/config"
|
||||
"github.com/Jinnrry/pmail/db"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/i18n"
|
||||
"github.com/Jinnrry/pmail/models"
|
||||
"github.com/Jinnrry/pmail/session"
|
||||
"github.com/Jinnrry/pmail/utils/array"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
"github.com/Jinnrry/pmail/utils/errors"
|
||||
"github.com/Jinnrry/pmail/utils/password"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
"pmail/config"
|
||||
"pmail/db"
|
||||
"pmail/dto/response"
|
||||
"pmail/i18n"
|
||||
"pmail/models"
|
||||
"pmail/session"
|
||||
"pmail/utils/array"
|
||||
"pmail/utils/context"
|
||||
"pmail/utils/errors"
|
||||
"pmail/utils/password"
|
||||
)
|
||||
|
||||
type loginRequest struct {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"net/http"
|
||||
"pmail/dto/response"
|
||||
)
|
||||
|
||||
func Ping(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
+10
-10
@@ -2,19 +2,19 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/db"
|
||||
"github.com/Jinnrry/pmail/dto"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/i18n"
|
||||
"github.com/Jinnrry/pmail/models"
|
||||
"github.com/Jinnrry/pmail/services/rule"
|
||||
"github.com/Jinnrry/pmail/utils/address"
|
||||
"github.com/Jinnrry/pmail/utils/array"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
"github.com/Jinnrry/pmail/utils/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
"pmail/db"
|
||||
"pmail/dto"
|
||||
"pmail/dto/response"
|
||||
"pmail/i18n"
|
||||
"pmail/models"
|
||||
"pmail/services/rule"
|
||||
"pmail/utils/address"
|
||||
"pmail/utils/array"
|
||||
"pmail/utils/context"
|
||||
"pmail/utils/errors"
|
||||
)
|
||||
|
||||
func GetRule(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
@@ -2,14 +2,14 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/db"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/i18n"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
"github.com/Jinnrry/pmail/utils/password"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
"pmail/db"
|
||||
"pmail/dto/response"
|
||||
"pmail/i18n"
|
||||
"pmail/utils/context"
|
||||
"pmail/utils/password"
|
||||
)
|
||||
|
||||
type modifyPasswordRequest struct {
|
||||
|
||||
@@ -2,16 +2,16 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/config"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/services/setup"
|
||||
"github.com/Jinnrry/pmail/services/setup/ssl"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"pmail/config"
|
||||
"pmail/dto/response"
|
||||
"pmail/services/setup"
|
||||
"pmail/services/setup/ssl"
|
||||
"pmail/utils/context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,18 +2,18 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/config"
|
||||
"github.com/Jinnrry/pmail/db"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/models"
|
||||
"github.com/Jinnrry/pmail/utils/array"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
"github.com/Jinnrry/pmail/utils/password"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
"io"
|
||||
"math"
|
||||
"net/http"
|
||||
"pmail/config"
|
||||
"pmail/db"
|
||||
"pmail/dto/response"
|
||||
"pmail/models"
|
||||
"pmail/utils/array"
|
||||
"pmail/utils/context"
|
||||
"pmail/utils/password"
|
||||
)
|
||||
|
||||
type userCreateRequest struct {
|
||||
|
||||
Reference in new issue
Block a user