mirror of
https://github.com/Jinnrry/PMail.git
synced 2025-11-03 02:43:31 +08:00
RFC 5322 添加MessageId
This commit is contained in:
@@ -168,6 +168,8 @@ func Send(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
e.MessageId = emailId
|
||||
|
||||
async.New(ctx).Process(func(p any) {
|
||||
errMsg := ""
|
||||
err, sendErr := send.Send(ctx, e)
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
_ "github.com/emersion/go-message/charset"
|
||||
"github.com/emersion/go-message/mail"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
"io"
|
||||
"net/textproto"
|
||||
"pmail/utils/array"
|
||||
@@ -54,6 +55,7 @@ type Email struct {
|
||||
IsRead int
|
||||
Status int // 0未发送,1已发送,2发送失败,3删除
|
||||
GroupId int // 分组id
|
||||
MessageId int64
|
||||
}
|
||||
|
||||
func NewEmailFromReader(to []string, r io.Reader) *Email {
|
||||
@@ -204,6 +206,7 @@ func (e *Email) ForwardBuildBytes(ctx *context.Context, forwardAddress string) [
|
||||
h.SetAddressList("From", from)
|
||||
h.SetAddressList("To", to)
|
||||
h.SetText("Subject", e.Subject)
|
||||
h.SetMessageID(cast.ToString(e.MessageId))
|
||||
if len(e.Cc) != 0 {
|
||||
cc := []*mail.Address{}
|
||||
for _, user := range e.Cc {
|
||||
@@ -291,7 +294,7 @@ func (e *Email) BuildBytes(ctx *context.Context, dkim bool) []byte {
|
||||
} else {
|
||||
h.SetDate(time.Now())
|
||||
}
|
||||
|
||||
h.SetMessageID(cast.ToString(e.MessageId))
|
||||
h.SetAddressList("From", from)
|
||||
h.SetAddressList("To", to)
|
||||
h.SetText("Subject", e.Subject)
|
||||
|
||||
@@ -140,7 +140,7 @@ func saveEmail(ctx *context.Context, email *parsemail.Email, emailType int, SPFS
|
||||
}
|
||||
|
||||
sql := "INSERT INTO email (type, send_date, subject, reply_to, from_name, from_address, `to`, bcc, cc, text, html, sender, attachments,spf_check, dkim_check, create_time,is_read,status,group_id) VALUES (?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||
_, err := db.Instance.Exec(sql,
|
||||
res, err := db.Instance.Exec(sql,
|
||||
emailType,
|
||||
email.Date,
|
||||
email.Subject,
|
||||
@@ -165,6 +165,10 @@ func saveEmail(ctx *context.Context, email *parsemail.Email, emailType int, SPFS
|
||||
if err != nil {
|
||||
log.WithContext(ctx).Println("mysql insert error:", err.Error())
|
||||
}
|
||||
insertId, _ := res.LastInsertId()
|
||||
if insertId > 0 {
|
||||
email.MessageId = insertId
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user