pop3

package
v0.0.0-...-08290b3 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Noop

func Noop() option

Noop is a configuration function that does nothing.

func UseTLS

func UseTLS(config *tls.Config) option

UseTLS is a configuration function whose result is passed as a parameter in the Dial function. It configures the client to use TLS.

func UseTimeout

func UseTimeout(timeout time.Duration) option

UseTimeout is a configuration function whose result is passed as a parameter in the Dial function. It configures the client to use timeouts for each POP3 command.

Types

type Client

type Client struct {
	Text *Connection
	// contains filtered or unexported fields
}

Client for POP3.

func Dial

func Dial(addr string, options ...option) (*Client, error)

Dial connects to the given address and returns a client holding a tcp connection. To pass configuration to the Dial function use the methods UseTLS or UseTimeout. E.g. c, err = pop3.Dial(address, pop3.UseTLS(tlsConfig), pop3.UseTimeout(timeout))

func NewClient

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

NewClient initializeds a client. To pass configuration to the NewClient function use the methods UseTLS or UseTimeout. E.g. c, err = pop3.Dial(address, pop3.UseTLS(tlsConfig), pop3.UseTimeout(timeout))

func (*Client) Auth

func (client *Client) Auth(username, password string) (err error)

Auth sends the given username and password to the server.

func (*Client) Dele

func (client *Client) Dele(msg uint32) (err error)

Dele marks the given message as deleted.

func (*Client) List

func (client *Client) List(msgSeqNum uint32) (size uint32, err error)

List returns the size of the message referenced by the sequence number, if it exists. If the message does not exist, or another error is encountered, the returned size will be 0.

func (*Client) ListAll

func (client *Client) ListAll() (msgInfos []*MessageInfo, err error)

ListAll returns a list of MessageInfo for all messages, containing their sequence number and size.

func (*Client) Noop

func (client *Client) Noop() (err error)

Noop does nothing, but will prolong the end of the connection if the server has a timeout set.

func (*Client) Pass

func (client *Client) Pass(password string) (err error)

Pass sends the given password to the server. The password is sent unencrypted unless the connection is already secured by TLS (via DialTLS or some other mechanism).

func (*Client) Quit

func (client *Client) Quit() (err error)

Quit sends the QUIT message to the POP3 server and closes the connection.

func (*Client) Retr

func (client *Client) Retr(msg uint32) (text string, err error)

Retr downloads and returns the given message. The lines are separated by LF, whatever the server sent.

func (*Client) Rset

func (client *Client) Rset() (err error)

Rset unmarks any messages marked for deletion previously in this session.

func (*Client) Stat

func (client *Client) Stat() (count, size uint32, err error)

Stat retrieves a drop listing for the current maildrop, consisting of the number of messages and the total size (in octets) of the maildrop. Information provided besides the number of messages and the size of the maildrop is ignored. In the event of an error, all returned numeric values will be 0.

func (*Client) UIDl

func (client *Client) UIDl(msgSeqNum uint32) (uid string, err error)

UIDl retrieves the unique ID of the message referenced by the sequence number.

func (*Client) UIDlAll

func (client *Client) UIDlAll() (msgInfos []*MessageInfo, err error)

UIDlAll retrieves the unique IDs and sequence number for all messages.

func (*Client) UseTimeouts

func (client *Client) UseTimeouts(timeout time.Duration)

UseTimeouts adds a timeout to the client. Timeouts are applied on every POP3 command.

func (*Client) User

func (client *Client) User(user string) (err error)

User issues the POP3 User command.

type Connection

type Connection struct {
	Reader *bufio.Reader
	Writer *bufio.Writer
	// contains filtered or unexported fields
}

Connection stores a Reader and a Writer.

func NewConnection

func NewConnection(conn io.ReadWriteCloser) *Connection

NewConnection initializes a connection.

func (*Connection) Close

func (c *Connection) Close() error

Close closes a connection.

func (*Connection) Cmd

func (c *Connection) Cmd(format string, args ...interface{}) (result string, err error)

Cmd sends the given command on the connection.

func (*Connection) ReadMultiLines

func (c *Connection) ReadMultiLines() (lines []string, err error)

ReadMultiLines reads a response with multiple lines.

func (*Connection) ReadResponse

func (c *Connection) ReadResponse() (result string, err error)

ReadResponse reads the response from the server and parses it. It checks whether the response is OK and returns the result omitting the OK+ prefix.

func (*Connection) SendCMD

func (c *Connection) SendCMD(format string, args ...interface{})

SendCMD writes the command on the writer and flushes the writer afterwards.

type MessageInfo

type MessageInfo struct {
	Seq  uint32 // Message sequence number
	Size uint32 // Message size in bytes
	UID  string // Message UID
}

MessageInfo represents the message attributes returned by a LIST command.

Jump to

Keyboard shortcuts

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