feature/v2.7.3

pop协议数据中增加messageId字段
This commit is contained in:
jinnrry 2024-09-28 11:05:27 +08:00
parent 473206f1fc
commit 3537fa335e
3 changed files with 26 additions and 6 deletions

View File

@ -4,6 +4,7 @@ import (
"database/sql"
"encoding/json"
"github.com/Jinnrry/pmail/dto/parsemail"
"github.com/spf13/cast"
"time"
)
@ -122,6 +123,7 @@ func (d *Email) MarshalJSON() ([]byte, error) {
func (d *Email) ToTransObj() *parsemail.Email {
return &parsemail.Email{
MessageId: cast.ToInt64(d.Id),
From: &parsemail.User{
Name: d.FromName,
EmailAddress: d.FromAddress,

View File

@ -67,6 +67,8 @@ func (a action) Capa(session *gopop.Session) ([]string, error) {
ret = append(ret, "STLS")
}
log.WithContext(session.Ctx).Debugf("CAPA \n %+v", ret)
return ret, nil
}
@ -175,6 +177,7 @@ func (a action) Uidl(session *gopop.Session, msg string) ([]gopop.UidlItem, erro
reqId := cast.ToInt64(msg)
if reqId > 0 {
log.WithContext(session.Ctx).Debugf("Uidl \n %+v", reqId)
return []gopop.UidlItem{
{
Id: reqId,
@ -199,6 +202,8 @@ func (a action) Uidl(session *gopop.Session, msg string) ([]gopop.UidlItem, erro
UnionId: cast.ToString(re.Id),
})
}
log.WithContext(session.Ctx).Debugf("Uidl \n %+v", ret)
return ret, nil
}
@ -224,17 +229,25 @@ func (a action) List(session *gopop.Session, msg string) ([]gopop.MailInfo, erro
if err != nil {
return nil, err
}
res = append(res, listItem{
item := listItem{
Id: cast.ToInt64(info.Id),
Size: cast.ToInt64(info.Size),
})
}
if item.Size == 0 {
item.Size = 9999
}
res = append(res, item)
} else {
emailList, _ := list.GetEmailList(session.Ctx.(*context.Context), dto.SearchTag{Type: consts.EmailTypeReceive, Status: -1, GroupId: -1}, "", true, 0, 99999)
for _, info := range emailList {
res = append(res, listItem{
item := listItem{
Id: cast.ToInt64(info.Id),
Size: cast.ToInt64(info.Size),
})
}
if item.Size == 0 {
item.Size = 9999
}
res = append(res, item)
}
}
ret := []gopop.MailInfo{}
@ -244,6 +257,8 @@ func (a action) List(session *gopop.Session, msg string) ([]gopop.MailInfo, erro
Size: re.Size,
})
}
log.WithContext(session.Ctx).Debugf("List \n %+v", ret)
return ret, nil
}
@ -257,6 +272,7 @@ func (a action) Retr(session *gopop.Session, id int64) (string, int64, error) {
}
ret := email.ToTransObj().BuildBytes(session.Ctx.(*context.Context), false)
log.WithContext(session.Ctx).Debugf("Retr \n %+v", string(ret))
return string(ret), cast.ToInt64(len(ret)), nil
}
@ -297,7 +313,9 @@ func (a action) Top(session *gopop.Session, id int64, n int) (string, error) {
return string(ret), nil
}
return array.Join(res[0:headerEndLine+n+1], "\n"), nil
lines := array.Join(res[0:headerEndLine+n+1], "\n")
log.WithContext(session.Ctx).Debugf("Top \n %+v", lines)
return lines, nil
}

View File

@ -149,7 +149,7 @@ func Send(ctx *context.Context, e *parsemail.Email) (error, map[string]error) {
mxHost: "smtp." + args[1],
}
if err != nil {
log.WithContext(ctx).Errorf(s.EmailAddress, "域名mx记录查询失败")
log.WithContext(ctx).Errorf(s.EmailAddress, "域名mx记录查询失败,检查邮箱是否存在!")
}
if len(mxInfo) > 0 {
address = mxDomain{