pop3

package
v0.0.0-...-e48ae90 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2015 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AUTHORIZATION = iota
	TRANSACTION
	UPDATE
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth interface {
	Auth(conn *Conn) (Maildrop, error)
}

type Client

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

The POP3 client.

func Dial

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

Dial creates an unsecured connection to the POP3 server at the given address and returns the corresponding Client.

func DialTLS

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

DialTLS creates a TLS-secured connection to the POP3 server at the given address and returns the corresponding Client.

func NewClient

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

NewClient returns a new Client object using an existing connection.

func (*Client) Auth

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

Auth sends the given username and password to the server, calling the User and Pass methods as appropriate.

func (*Client) Cmd

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

Convenience function to synchronously run an arbitrary command and wait for output. The terminating CRLF must be included in the format string.

Output sent after the first line must be retrieved via readLines.

func (*Client) Dele

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

Dele marks the given message as deleted.

func (*Client) List

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

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

func (*Client) ListAll

func (c *Client) ListAll() (msgs []int, sizes []int, err error)

ListAll returns a list of all messages and their sizes.

func (*Client) Noop

func (c *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 (c *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). Generally, there is no reason not to use the Auth convenience method.

func (*Client) Quit

func (c *Client) Quit() error

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

func (*Client) ReadLines

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

func (*Client) Retr

func (c *Client) Retr(msg int) (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 (c *Client) Rset() (err error)

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

func (*Client) Stat

func (c *Client) Stat() (count, size int, 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) User

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

User sends the given username to the server. Generally, there is no reason not to use the Auth convenience method.

type Conn

type Conn struct {
	net.Conn
	IsTLS    bool
	Errors   []error
	MaxSize  int
	Maildrop Maildrop

	// transaction int
	State int
	// contains filtered or unexported fields
}

func (*Conn) ReadPOP

func (c *Conn) ReadPOP() (string, string, error)

ReadSMTP pulls a single POP3 command line (ending in a carriage return + newline (aka CRLF))

func (*Conn) ReadUntil

func (c *Conn) ReadUntil(suffix string) (value string, err error)

rawRead performs the actual read from the connection, reading each line up to the first occurrence of suffix

func (*Conn) Reset

func (c *Conn) Reset()

func (*Conn) WriteERR

func (c *Conn) WriteERR(message string) error

WriteERR responds with a POP3 failure message

func (*Conn) WriteOK

func (c *Conn) WriteOK(message string) error

WriteOK response with a POP3 success message

type Maildrop

type Maildrop interface {

	// Lock the maildrop
	Lock() error

	// Unlock the maildrop
	Unlock() error

	// Count returns the number of messages in the maildrop
	Count() int

	// Flag a message for deletion
	Flag(message int) error

	// Delete performs the UPDATE state deletion step
	Delete() error
}

type MessageHandler

type MessageHandler func(m *email.Message) error

MessageHandler functions handle application of business logic to the inbound message

type Server

type Server struct {
	Name string

	TLSConfig  *tls.Config
	ServerName string

	// MaxSize of incoming message objects, zero for no cap otherwise
	// larger messages are thrown away
	MaxSize int

	// MaxConn limits the number of concurrent connections being handled
	MaxConn int

	// MaxCommands is the maximum number of commands a server will accept
	// from a single client before terminating the session
	MaxCommands int

	// RateLimiter gets called before proceeding through to message handling
	RateLimiter func(*Conn) bool

	// Handler is the handoff function for messages
	Handler MessageHandler

	// Maildrop is a dropping point for a mail message
	Maildrop Maildrop

	// Disabled features
	Disabled map[string]bool

	// help message to display in response to a HELP request
	Help string
	// contains filtered or unexported fields
}

func NewServer

func NewServer(maildrop Maildrop) *Server

NewServer creates a server with the default settings

func (*Server) Address

func (s *Server) Address() string

func (*Server) Close

func (s *Server) Close()

Close the server connection (not happy with this)

func (*Server) GetAddressArg

func (s *Server) GetAddressArg(argName string, args string) (*mail.Address, error)

func (*Server) HandlePOP3

func (s *Server) HandlePOP3(conn *Conn) error

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

ListenAndServe starts listening for SMTP commands at the supplied TCP address

func (*Server) SetHelp

func (s *Server) SetHelp(message string) error

SetHelp sets a help message

func (*Server) UseTLS

func (s *Server) UseTLS(cert, key string) error

UseTLS tries to enable TLS on the server (can also just explicitly set the TLSConfig)

Jump to

Keyboard shortcuts

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