pop3

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EOF = errors.New("skip the all mail remaining")
)

Functions

func DoPop3

func DoPop3(address, user, pass string) bool

pop3密码破解

func ReceiveMail

func ReceiveMail(addr, user, pass string, receiveFn ReceiveMailFunc) error

ReceiveMail connects to the server at addr, and authenticates with user and pass, and calling receiveFn for each mail.

Types

type Client

type Client struct {
	// Text is the pop3.Conn used by the Client.
	Text *Conn
	// contains filtered or unexported fields
}

A Client represents a client connection to an POP server.

func Dial

func Dial(addr string) (*Client, error)

Dial returns a new Client connected to an POP server at addr. The addr must include a port number.

func NewClient

func NewClient(conn net.Conn) (*Client, error)

NewClient returns a new Client using an existing connection.

func (*Client) Close

func (c *Client) Close() error

func (*Client) Dele

func (c *Client) Dele(number int) error

Dele issues a DELE command to the server using the provided mail number.

func (*Client) List

func (c *Client) List(number int) (int, uint64, error)

List issues a LIST command to the server using the provided mail number and returns mail number and size.

func (*Client) ListAll

func (c *Client) ListAll() ([]MessageInfo, error)

List issues a LIST command to the server and returns array of MessageInfo.

func (*Client) Noop

func (c *Client) Noop() error

Noop issues a NOOP command to the server.

func (*Client) Pass

func (c *Client) Pass(pass string) error

Pass issues a PASS command to the server using the provided password.

func (*Client) Quit

func (c *Client) Quit() error

Quit issues a QUIT command to the server.

func (*Client) Retr

func (c *Client) Retr(number int) (string, error)

Retr issues a RETR command to the server using the provided mail number and returns mail data.

func (*Client) Rset

func (c *Client) Rset() error

Rset issues a RSET command to the server.

func (*Client) Stat

func (c *Client) Stat() (int, uint64, error)

Stat issues a STAT command to the server and returns mail count and total size.

func (*Client) Uidl

func (c *Client) Uidl(number int) (int, string, error)

Uidl issues a UIDL command to the server using the provided mail number and returns mail number and unique id.

func (*Client) UidlAll

func (c *Client) UidlAll() ([]MessageInfo, error)

Uidl issues a UIDL command to the server and returns array of MessageInfo.

func (*Client) User

func (c *Client) User(user string) error

User issues a USER command to the server using the provided user name.

type Conn

type Conn struct {
	Reader
	Writer
	// contains filtered or unexported fields
}

A Conn represents a textual network protocol connection for POP3.

func NewConn

func NewConn(conn io.ReadWriteCloser) *Conn

NewConn returns a new Conn using conn for I/O.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection.

type MessageInfo

type MessageInfo struct {
	Number int
	Size   uint64
	Uid    string
}

MessageInfo has Number, Size, and Uid fields, and used as a return value of ListAll and UidlAll. When used as the return value of the method ListAll, MessageInfo contain only the Number and Size values. When used as the return value of the method UidlAll, MessageInfo contain only the Number and Uid values.

type Reader

type Reader struct {
	R *textproto.Reader
}

A Reader implements convenience methods for reading requests or responses from a text protocol network connection.

func NewReader

func NewReader(r *bufio.Reader) *Reader

NewReader returns a new Reader reading from r.

func (*Reader) ReadLine

func (r *Reader) ReadLine() (string, error)

ReadLine reads a single line from r, eliding the final \n or \r\n from the returned string. This calls textproto.Reader.ReadLine simply.

func (*Reader) ReadLines

func (r *Reader) ReadLines() ([]string, error)

ReadLines reads a multiline until the last line of the only period, and returns a each line at slice. it does not contain last period.

func (*Reader) ReadResponse

func (r *Reader) ReadResponse() (string, error)

ReadResponse reads a single line from r, and parses reponse. if the response is -ERR or has some other errors, it returns error.

func (*Reader) ReadToPeriod

func (r *Reader) ReadToPeriod() (string, error)

ReadToPeriod reads a multiline until the last line of the only period, and returns as a string. it does not contain last period.

type ReceiveMailFunc

type ReceiveMailFunc func(number int, uid, data string, err error) (bool, error)

ReceiveMailFunc is the type of the function called for each mail. Its arguments are mail's number, uid, data, and mail receiving error. if this function returns false value, the mail will be deleted, if its returns EOF, skip the all mail of remaining. (after deleting mail, if necessary)

type ResponseError

type ResponseError string

A ResponseError describes a protocol violation such as an invalid response or a hung-up connection.

func (ResponseError) Error

func (r ResponseError) Error() string

type Writer

type Writer struct {
	W *bufio.Writer
}

A Writer implements convenience methods for writing requests or responses to a text protocol network connection.

func NewWriter

func NewWriter(w *bufio.Writer) *Writer

NewWriter returns a new Writer writing to w.

func (*Writer) WriteLine

func (w *Writer) WriteLine(format string, args ...interface{}) error

WriteLine writes the formatted output followed by \r\n.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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