Documentation ¶
Overview ¶
Package pop3client is borrowed directly from https://github.com/knadh/go-pop3 to reduce dependencies. This is used solely for testing the POP3 server
Index ¶
- type Client
- type Conn
- func (c *Conn) Auth(user, password string) error
- func (c *Conn) Cmd(cmd string, isMulti bool, args ...interface{}) (*bytes.Buffer, error)
- func (c *Conn) Dele(msgID ...int) error
- func (c *Conn) List(msgID int) ([]MessageID, error)
- func (c *Conn) Noop() error
- func (c *Conn) Pass(s string) error
- func (c *Conn) Quit() error
- func (c *Conn) ReadAll() (*bytes.Buffer, error)
- func (c *Conn) ReadOne() ([]byte, error)
- func (c *Conn) Retr(msgID int) (*mail.Message, error)
- func (c *Conn) RetrRaw(msgID int) (*bytes.Buffer, error)
- func (c *Conn) Rset() error
- func (c *Conn) Send(b string) error
- func (c *Conn) Stat() (int, int, error)
- func (c *Conn) Top(msgID int, numLines int) (*mail.Message, error)
- func (c *Conn) Uidl(msgID int) ([]MessageID, error)
- func (c *Conn) User(s string) error
- type Dialer
- type MessageID
- type Opt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements a Client e-mail client.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a stateful connection with the POP3 server/
func (*Conn) Cmd ¶
Cmd sends a command to the server. POP3 responses are either single line or multi-line. The first line always with -ERR in case of an error or +OK in case of a successful operation. OK+ is always followed by a response on the same line which is either the actual response data in case of single line responses, or a help message followed by multiple lines of actual response data in case of multiline responses. See https://www.shellhacks.com/retrieve-email-pop3-server-command-line/ for examples.
func (*Conn) Dele ¶
Dele deletes one or more messages. The server only executes the deletions after a successful Quit().
func (*Conn) List ¶
List returns a list of (message ID, message Size) pairs. If the optional msgID > 0, then only that particular message is listed. The message IDs are sequential, 1 to N.
func (*Conn) Noop ¶
Noop issues a do-nothing NOOP command to the server. This is useful for prolonging open connections.
func (*Conn) Quit ¶
Quit sends the QUIT command to server and gracefully closes the connection. Message deletions (DELE command) are only executed by the server on a graceful quit and close.
func (*Conn) ReadAll ¶
ReadAll reads all lines from the connection until the POP3 multiline terminator "." is encountered and returns a bytes.Buffer of all the read lines.
func (*Conn) Retr ¶
Retr downloads a message by the given msgID, parses it and returns it as a *mail.Message.
func (*Conn) RetrRaw ¶
RetrRaw downloads a message by the given msgID and returns the raw []byte of the entire message.
func (*Conn) Send ¶
Send sends a POP3 command to the server. The given comand is suffixed with "\r\n".
func (*Conn) Top ¶
Top retrieves a message by its ID with full headers and numLines lines of the body.
type MessageID ¶
type MessageID struct { // ID is the numerical index (non-unique) of the message. ID int // Size in bytes Size int // UID is only present if the response is to the UIDL command. UID string }
MessageID contains the ID and size of an individual message.
type Opt ¶
type Opt struct { // Host name Host string `json:"host"` // Port number Port int `json:"port"` // DialTimeout default is 3 seconds. DialTimeout time.Duration `json:"dial_timeout"` // Dialer Dialer Dialer `json:"-"` // TLSEnabled sets whether SLS is enabled TLSEnabled bool `json:"tls_enabled"` // TLSSkipVerify skips TLS verification (ie: self-signed) TLSSkipVerify bool `json:"tls_skip_verify"` }
Opt represents the client configuration.