gopop

package module
v0.0.0-...-fbdf52a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 11 Imported by: 0

README

GoPOP

A simple Go POP3 Server library


import (
    "github.com/Jinnrry/gopop"
    "pmail/config"
)

type action struct {
}
func (a action) User(session *Session, username string) error {
//TODO implement me
panic("implement me")
}

func (a action) Pass(session *Session, password string) error {
//TODO implement me
panic("implement me")
}

func (a action) Apop(session *Session, username, digest string) error {
//TODO implement me
panic("implement me")
}

func (a action) Stat(session *Session) (msgNum, msgSize int64, err error) {
//TODO implement me
panic("implement me")
}

func (a action) Uidl(session *Session, msg string) ([]UidlItem, error) {
//TODO implement me
panic("implement me")
}

func (a action) List(session *Session, msg string) ([]MailInfo, error) {
//TODO implement me
panic("implement me")
}

func (a action) Retr(session *Session, id int64) (string, int64, error) {
//TODO implement me
panic("implement me")
}

func (a action) Delete(session *Session, id int64) error {
//TODO implement me
panic("implement me")
}

func (a action) Rest(session *Session) error {
//TODO implement me
panic("implement me")
}

func (a action) Top(session *Session, id int64, n int) (string, error) {
//TODO implement me
panic("implement me")
}

func (a action) Noop(session *Session) error {
//TODO implement me
panic("implement me")
}

func (a action) Quit(session *Session) error {
//TODO implement me
panic("implement me")
}

func (a action) Capa(session *Session) ([]string, error) {
//TODO implement me
panic("implement me")
}

func (a action) Custom(session *Session, cmd string, args []string) ([]string, error) {
//TODO implement me
panic("implement me")
}

func Start() {
    pop3instance := gopop.NewPop3Server(110, "domain.com", false, nil, action{})
    pop3instance.Start()

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	User(session *Session, username string) error
	Pass(session *Session, password string) error
	Apop(session *Session, username, digest string) error
	Stat(session *Session) (msgNum, msgSize int64, err error)
	Uidl(session *Session, msg string) ([]UidlItem, error)
	List(session *Session, msg string) ([]MailInfo, error)
	Retr(session *Session, id int64) (string, int64, error)
	Delete(session *Session, id int64) error
	Rest(session *Session) error
	Top(session *Session, id int64, n int) (string, error)
	Noop(session *Session) error
	Quit(session *Session) error
	Capa(session *Session) ([]string, error)
	Custom(session *Session, cmd string, args []string) ([]string, error)
}

type MailInfo

type MailInfo struct {
	Id   int64
	Size int64
}

type Server

type Server struct {
	Domain           string        // 域名
	Port             int           // 端口
	TlsEnabled       bool          //是否启用Tls
	TlsConfig        *tls.Config   // tls配置
	ConnectAliveTime time.Duration // 连接存活时间,默认不超时
	Action           Action
	// contains filtered or unexported fields
}

Server Pop3服务实例

func NewPop3Server

func NewPop3Server(port int, domain string, tlsEnabled bool, tlsConfig *tls.Config, action Action) *Server

NewPop3Server 新建一个服务实例

func (*Server) Start

func (s *Server) Start() error

Start 启动服务

func (*Server) Stop

func (s *Server) Stop()

Stop 停止服务

type Session

type Session struct {
	Status    Status
	User      string
	DeleteIds []int64
	Ctx       context.Context
	Conn      net.Conn
	InTls     bool
	AliveTime time.Time
}

type Status

type Status int8
const (
	UNAUTHORIZED Status = 1
	TRANSACTION  Status = 2
	UPDATE       Status = 3
)

type UidlItem

type UidlItem struct {
	Id      int64
	UnionId string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL