pop3

package module
v0.0.0-...-2ffa7ad Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2018 License: BSD-2-Clause Imports: 9 Imported by: 0

README

Protocol rfc1939 Protocol rfc1939 License

Go v1.9 Go Report Card GoDoc

Post Office Protocol - Version 3 (POP3)

Including Optional POP3 Commands:
  • TOP
  • UIDL

Example

// Create a connection to the server
c, err := pop3.DialTLS("pop.gmx.com:995", false)
if err != nil {
	log.Fatal(err)
}
defer c.Quit()

// Authenticate with the server
if err = c.Auth("username", "password"); err != nil {
	log.Fatal(err)
}

// Print the UID of all messages in the maildrop
messages, err := c.UidlAll()
if err != nil {
	log.Fatal(err)
}
for _, v := range messages {
	log.Print(v.UID)
}

Documentation

Overview

Package pop3 provides an implementation of the Post Office Protocol - Version 3.

Index

Constants

View Source
const (
	USER = "USER"
	PASS = "PASS"
	QUIT = "QUIT"
	STAT = "STAT"
	LIST = "LIST"
	RETR = "RETR"
	DELE = "DELE"
	NOOP = "NOOP"
	RSET = "RSET"
)

Non optional POP3 commands as extracted from rfc1939 section 5 and 6.

View Source
const (
	ATOP = "ATOP"
	TOP  = "TOP"
	UIDL = "UIDL"
)

Optional POP3 commands as extracted from rfc1939 section 7.

View Source
const (
	OK  = "+OK"
	ERR = "-ERR"
)

POP3 replies as extracted from rfc1939 section 9.

Variables

This section is empty.

Functions

func IsErr

func IsErr(s string) bool

IsErr checks to see if the reply from the server contains +Err.

func IsOK

func IsOK(s string) bool

IsOK checks to see if the reply from the server contains +OK.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client holds the net conn and read/write buffer objects.

func Dial

func Dial(address string) (c *Client, err error)

Dial connects to the address on the named network.

func DialTLS

func DialTLS(address string, selfsigned bool) (c *Client, err error)

DialTLS connects to the address on the named network using tls.

func NewClient

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

NewClient returns a new client object using an existing connection.

func (*Client) Auth

func (c *Client) Auth(u, p string) (err error)

Auth sends the username and password to the server using the User and Pass methods. Noop is also called incase the server does not respond with invalid auth.

func (*Client) Cmd

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

Cmd sends a command to the server and returns a single line from the buffer.

func (*Client) Dele

func (c *Client) Dele(msg int) (err error)

Dele will delete the given message from the maildrop. Changes will only take affect after the Quit command is issued.

func (*Client) List

func (c *Client) List(msg int) (list MessageList, err error)

List returns the MessageList object which contains the message non unique id and its size.

func (*Client) ListAll

func (c *Client) ListAll() (list []MessageList, err error)

ListAll returns a MessageList object which contains all messages in the maildrop.

func (*Client) Noop

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

Noop will do nothing however can prolong the end of a connection.

func (*Client) Pass

func (c *Client) Pass(p string) (err error)

Pass sends the password to the server.

func (*Client) Quit

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

Quit sends the quit command to the server and closes the socket.

func (*Client) ReadLine

func (c *Client) ReadLine() (line string, err error)

ReadLine reads a single line from the buffer.

func (*Client) ReadLines

func (c *Client) ReadLines() (lines []string, err error)

ReadLines reads from the buffer until it hits the message end dot (".").

func (*Client) Retr

func (c *Client) Retr(msg int) (m *mail.Message, err error)

Retr downloads the given message and returns it as a mail.Message object.

func (*Client) Rset

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

Rset will unmark any messages that have being marked for deletion in the current session.

func (*Client) Send

func (c *Client) Send(format string, args ...interface{}) (err error)

Send writes a command to the buffer and flushes it. Does not return any lines from the buffer.

func (*Client) Stat

func (c *Client) Stat() (count, size int, err error)

Stat retreives a listing for the current maildrop, consisting of the number of messages and the total size of the maildrop.

func (*Client) Top

func (c *Client) Top(msg int, n int) (m *mail.Message, err error)

Top will return a varible number of lines for a given message as a mail.Message object.

func (*Client) Uidl

func (c *Client) Uidl(msg int) (list MessageUidl, err error)

Uidl will return a MessageUidl object which contains the message non unique id and a unique id.

func (*Client) UidlAll

func (c *Client) UidlAll() (list []MessageUidl, err error)

UidlAll will return a MessageUidl object which contains all messages in the maildrop.

func (*Client) User

func (c *Client) User(u string) (err error)

User sends the username to the server.

type MessageList

type MessageList struct {
	// Non unique id reported by the server
	ID int

	// Size of the message
	Size int
}

MessageList represents the metadata returned by the server for a message stored in the maildrop.

type MessageUidl

type MessageUidl struct {
	// Non unique id reported by the server
	ID int

	// Unique id reported by the server
	UID string
}

MessageUidl represents the metadata returned by the server for a message stored in the maildrop.

Jump to

Keyboard shortcuts

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