Explorar o código

feature/v2.7.3

pop协议数据中增加messageId字段
jinnrry hai 1 ano
pai
achega
3537fa335e
Modificáronse 3 ficheiros con 26 adicións e 6 borrados
  1. 2 0
      server/models/email.go
  2. 23 5
      server/pop3_server/action.go
  3. 1 1
      server/utils/send/send.go

+ 2 - 0
server/models/email.go

@@ -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,

+ 23 - 5
server/pop3_server/action.go

@@ -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
 
 }
 

+ 1 - 1
server/utils/send/send.go

@@ -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{