Skip to content

Commit

Permalink
feature/v2.7.3 (#211)
Browse files Browse the repository at this point in the history
pop协议数据中增加messageId字段

Co-authored-by: jinnrry <[email protected]>
  • Loading branch information
Jinnrry and Jinnrry authored Sep 28, 2024
1 parent 473206f commit b86c258
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions server/models/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"database/sql"
"encoding/json"
"github.com/Jinnrry/pmail/dto/parsemail"
"github.com/spf13/cast"
"time"
)

Expand Down Expand Up @@ -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,
Expand Down
28 changes: 23 additions & 5 deletions server/pop3_server/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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,
Expand All @@ -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
}

Expand All @@ -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{}
Expand All @@ -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
}

Expand All @@ -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

}
Expand Down Expand Up @@ -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

}

Expand Down
2 changes: 1 addition & 1 deletion server/utils/send/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit b86c258

Please sign in to comment.