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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e.MessageId = emailId
|
||||||
|
|
||||||
async.New(ctx).Process(func(p any) {
|
async.New(ctx).Process(func(p any) {
|
||||||
errMsg := ""
|
errMsg := ""
|
||||||
err, sendErr := send.Send(ctx, e)
|
err, sendErr := send.Send(ctx, e)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
_ "github.com/emersion/go-message/charset"
|
_ "github.com/emersion/go-message/charset"
|
||||||
"github.com/emersion/go-message/mail"
|
"github.com/emersion/go-message/mail"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"github.com/spf13/cast"
|
||||||
"io"
|
"io"
|
||||||
"net/textproto"
|
"net/textproto"
|
||||||
"pmail/utils/array"
|
"pmail/utils/array"
|
||||||
@@ -54,6 +55,7 @@ type Email struct {
|
|||||||
IsRead int
|
IsRead int
|
||||||
Status int // 0未发送,1已发送,2发送失败,3删除
|
Status int // 0未发送,1已发送,2发送失败,3删除
|
||||||
GroupId int // 分组id
|
GroupId int // 分组id
|
||||||
|
MessageId int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEmailFromReader(to []string, r io.Reader) *Email {
|
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("From", from)
|
||||||
h.SetAddressList("To", to)
|
h.SetAddressList("To", to)
|
||||||
h.SetText("Subject", e.Subject)
|
h.SetText("Subject", e.Subject)
|
||||||
|
h.SetMessageID(cast.ToString(e.MessageId))
|
||||||
if len(e.Cc) != 0 {
|
if len(e.Cc) != 0 {
|
||||||
cc := []*mail.Address{}
|
cc := []*mail.Address{}
|
||||||
for _, user := range e.Cc {
|
for _, user := range e.Cc {
|
||||||
@@ -291,7 +294,7 @@ func (e *Email) BuildBytes(ctx *context.Context, dkim bool) []byte {
|
|||||||
} else {
|
} else {
|
||||||
h.SetDate(time.Now())
|
h.SetDate(time.Now())
|
||||||
}
|
}
|
||||||
|
h.SetMessageID(cast.ToString(e.MessageId))
|
||||||
h.SetAddressList("From", from)
|
h.SetAddressList("From", from)
|
||||||
h.SetAddressList("To", to)
|
h.SetAddressList("To", to)
|
||||||
h.SetText("Subject", e.Subject)
|
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 (?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
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,
|
emailType,
|
||||||
email.Date,
|
email.Date,
|
||||||
email.Subject,
|
email.Subject,
|
||||||
@@ -165,6 +165,10 @@ func saveEmail(ctx *context.Context, email *parsemail.Email, emailType int, SPFS
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithContext(ctx).Println("mysql insert error:", err.Error())
|
log.WithContext(ctx).Println("mysql insert error:", err.Error())
|
||||||
}
|
}
|
||||||
|
insertId, _ := res.LastInsertId()
|
||||||
|
if insertId > 0 {
|
||||||
|
email.MessageId = insertId
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user