client

package
v0.0.0-...-90479f1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

An IMAP client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {

	// The server capabilities.
	Caps map[string]bool
	// The current connection state.
	State imap.ConnState
	// The selected mailbox, if there is one.
	Mailbox *imap.MailboxStatus

	// A channel where info messages from the server will be sent.
	Infos chan *imap.StatusResp
	// A channel where warning messages from the server will be sent.
	Warnings chan *imap.StatusResp
	// A channel where error messages from the server will be sent.
	Errors chan *imap.StatusResp
	// A channel where bye messages from the server will be sent.
	Byes chan *imap.StatusResp
	// A channel where mailbox updates from the server will be sent.
	MailboxUpdates chan *imap.MailboxStatus
	// A channel where deleted message IDs will be sent.
	Expunges chan uint32
	// contains filtered or unexported fields
}

An IMAP client.

func Dial

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

Connect to an IMAP server using an unencrypted connection.

func DialTLS

func DialTLS(addr string, tlsConfig *tls.Config) (c *Client, err error)

Connect to an IMAP server using an encrypted connection.

func NewClient

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

Create a new client from an existing connection.

func (*Client) Append

func (c *Client) Append(mbox string, flags []string, date *time.Time, msg *imap.Literal) (err error)

Appends the literal argument as a new message to the end of the specified destination mailbox. This argument SHOULD be in the format of an RFC 2822 message. flags and date are optional arguments and can be set to nil.

func (*Client) Authenticate

func (c *Client) Authenticate(auth sasl.Client) (err error)

Indicates a SASL authentication mechanism to the server. If the server supports the requested authentication mechanism, it performs an authentication protocol exchange to authenticate and identify the client.

func (*Client) Capability

func (c *Client) Capability() (caps map[string]bool, err error)

Request a listing of capabilities that the server supports. Capabilities are often returned by the server with the greeting or with the STARTTLS and LOGIN responses, so usually explicitely requesting capabilities isn't needed.

func (*Client) Check

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

Requests a checkpoint of the currently selected mailbox. A checkpoint refers to any implementation-dependent housekeeping associated with the mailbox that is not normally executed as part of each command.

func (*Client) Close

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

Permanently removes all messages that have the \Deleted flag set from the currently selected mailbox, and returns to the authenticated state from the selected state.

func (*Client) Copy

func (c *Client) Copy(seqset *imap.SeqSet, dest string) (err error)

Copies the specified message(s) to the end of the specified destination mailbox.

func (*Client) Create

func (c *Client) Create(name string) (err error)

Creates a mailbox with the given name.

func (*Client) Delete

func (c *Client) Delete(name string) (err error)

Permanently removes the mailbox with the given name.

func (*Client) Execute

func (c *Client) Execute(cmdr imap.Commander, res imap.RespHandlerFrom) (status *imap.StatusResp, err error)

Execute a generic command. cmdr is a value that can be converted to a raw command and res is a value that can handle responses. The function returns when the command has completed or failed, in this case err is nil. A non-nil err value indicates a network error.

This function should not be called directly, it must only be used by libraries implementing extensions of the IMAP protocol.

func (*Client) Expunge

func (c *Client) Expunge(ch chan uint32) (err error)

Permanently removes all messages that have the \Deleted flag set from the currently selected mailbox. If ch is not nil, sends sequence IDs of each deleted message to this channel.

func (*Client) Fetch

func (c *Client) Fetch(seqset *imap.SeqSet, items []string, ch chan *imap.Message) (err error)

Retrieves data associated with a message in the mailbox. See RFC 3501 section 6.4.5 for a list of items that can be requested.

func (*Client) IsTLS

func (c *Client) IsTLS() bool

Check if this client's connection has TLS enabled.

func (*Client) List

func (c *Client) List(ref, name string, ch chan *imap.MailboxInfo) (err error)

Returns a subset of names from the complete set of all names available to the client. An empty name argument is a special request to return the hierarchy delimiter and the root name of the name given in the reference. The character "*" is a wildcard, and matches zero or more characters at this position. The character "%" is similar to "*", but it does not match a hierarchy delimiter.

func (*Client) Login

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

Identifies the client to the server and carries the plaintext password authenticating this user.

func (*Client) Logout

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

Close the connection.

func (*Client) Lsub

func (c *Client) Lsub(ref, name string, ch chan *imap.MailboxInfo) (err error)

Returns a subset of names from the set of names that the user has declared as being "active" or "subscribed".

func (*Client) Noop

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

This command always succeeds. It does nothing. Can be used as a periodic poll for new messages or message status updates during a period of inactivity. Can also be used to reset any inactivity autologout timer on the server.

func (*Client) Rename

func (c *Client) Rename(existingName, newName string) (err error)

Changes the name of a mailbox.

func (*Client) Search

func (c *Client) Search(criteria *imap.SearchCriteria) (seqNums []uint32, err error)

Searches the mailbox for messages that match the given searching criteria. Searching criteria consist of one or more search keys. The response contains a list of message sequence IDs corresponding to those messages that match the searching criteria. When multiple keys are specified, the result is the intersection (AND function) of all the messages that match those keys. Criteria must be UTF-8 encoded. See RFC 3501 section 6.4.4 for a list of searching criteria.

func (*Client) Select

func (c *Client) Select(name string, readOnly bool) (mbox *imap.MailboxStatus, err error)

Selects a mailbox so that messages in the mailbox can be accessed. Any currently selected mailbox is deselected before attempting the new selection. Even if the readOnly parameter is set to false, the server can decide to open the mailbox in read-only mode.

func (*Client) StartTLS

func (c *Client) StartTLS(tlsConfig *tls.Config) (err error)

If the connection to the IMAP server isn't secure, starts TLS negociation.

func (*Client) Status

func (c *Client) Status(name string, items []string) (mbox *imap.MailboxStatus, err error)

Requests the status of the indicated mailbox. It does not change the currently selected mailbox, nor does it affect the state of any messages in the queried mailbox. See RFC 2501 section 6.3.10 for a list of items that can be requested.

func (*Client) Store

func (c *Client) Store(seqset *imap.SeqSet, item string, value interface{}, ch chan *imap.Message) (err error)

Alters data associated with a message in the mailbox. If ch is not nil, the updated value of the data will be sent to this channel. See RFC 3501 section 6.4.6 for a list of items that can be updated.

func (*Client) Subscribe

func (c *Client) Subscribe(name string) (err error)

Adds the specified mailbox name to the server's set of "active" or "subscribed" mailboxes.

func (*Client) SupportsAuthentication

func (c *Client) SupportsAuthentication(mech string) bool

Check if the server supports a given authentication mechanism.

func (*Client) SupportsStartTLS

func (c *Client) SupportsStartTLS() bool

Check if the server supports STARTTLS.

func (*Client) UidCopy

func (c *Client) UidCopy(seqset *imap.SeqSet, dest string) (err error)

Identical to Copy, but seqset is interpreted as containing unique identifiers instead of message sequence numbers.

func (*Client) UidFetch

func (c *Client) UidFetch(seqset *imap.SeqSet, items []string, ch chan *imap.Message) (err error)

Identical to Fetch, but seqset is interpreted as containing unique identifiers instead of message sequence numbers.

func (*Client) UidSearch

func (c *Client) UidSearch(criteria *imap.SearchCriteria) (uids []uint32, err error)

Identical to Search, but unique identifiers are returned instead of message sequence numbers.

func (*Client) UidStore

func (c *Client) UidStore(seqset *imap.SeqSet, item string, value interface{}, ch chan *imap.Message) (err error)

Identical to Store, but seqset is interpreted as containing unique identifiers instead of message sequence numbers.

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(name string) (err error)

Removes the specified mailbox name from the server's set of "active" or "subscribed" mailboxes.

func (*Client) Upgrade

func (c *Client) Upgrade(upgrader imap.ConnUpgrader) error

Upgrade a connection, e.g. wrap an unencrypted connection with an encrypted tunnel.

This function should not be called directly, it must only be used by libraries implementing extensions of the IMAP protocol.

Jump to

Keyboard shortcuts

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