package logic import ( "app.yhyue.com/moapp/jybase/mail" "bp.jydev.jianyu360.cn/BaseService/biService/entity" "context" "fmt" "time" "bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/svc" "bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb" "github.com/zeromicro/go-zero/core/logx" ) type SendCommonMailLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewSendCommonMailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendCommonMailLogic { return &SendCommonMailLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } func (l *SendCommonMailLogic) SendCommonMail(in *pb.SendMailReq) (*pb.BiReply, error) { for k, v := range entity.GmailAuth { fool := mail.GSendMail_q("剑鱼标讯", in.Mails, "", "", in.Title, in.Content, "", "", v) if fool { logx.Info(in.Mails, fmt.Sprintf("使用%s发送邮件成功", v.User)) break } if k < len(entity.GmailAuth)-1 { logx.Info(in.Mails, fmt.Sprintf("使用%s发送邮件失败!3s后使用其他邮箱尝试", v.User)) } else { logx.Info(in.Mails, fmt.Sprintf("使用%s发送邮件失败!", v.User)) } time.Sleep(time.Second * 3) } return &pb.BiReply{ ErrorCode: 0, ErrorMsg: "发送成功", Data: nil, }, nil }