Documentation
¶
Overview ¶
An IMAP client.
Index ¶
- Variables
- type Client
- func (c *Client) Append(mbox string, flags []string, date time.Time, msg *imap.Literal) (err error)
- func (c *Client) Authenticate(auth sasl.Client) (err error)
- func (c *Client) Capability() (caps map[string]bool, err error)
- func (c *Client) Check() (err error)
- func (c *Client) Close() (err error)
- func (c *Client) Copy(seqset *imap.SeqSet, dest string) (err error)
- func (c *Client) Create(name string) (err error)
- func (c *Client) Delete(name string) (err error)
- func (c *Client) Execute(cmdr imap.Commander, res imap.RespHandlerFrom) (status *imap.StatusResp, err error)
- func (c *Client) Expunge(ch chan uint32) (err error)
- func (c *Client) Fetch(seqset *imap.SeqSet, items []string, ch chan *imap.Message) (err error)
- func (c *Client) IsTLS() bool
- func (c *Client) List(ref, name string, ch chan *imap.MailboxInfo) (err error)
- func (c *Client) LoggedOut() <-chan struct{}
- func (c *Client) Login(username, password string) (err error)
- func (c *Client) Logout() (err error)
- func (c *Client) Lsub(ref, name string, ch chan *imap.MailboxInfo) (err error)
- func (c *Client) Noop() (err error)
- func (c *Client) Rename(existingName, newName string) (err error)
- func (c *Client) Search(criteria *imap.SearchCriteria) (seqNums []uint32, err error)
- func (c *Client) Select(name string, readOnly bool) (mbox *imap.MailboxStatus, err error)
- func (c *Client) StartTLS(tlsConfig *tls.Config) (err error)
- func (c *Client) Status(name string, items []string) (mbox *imap.MailboxStatus, err error)
- func (c *Client) Store(seqset *imap.SeqSet, item string, value interface{}, ch chan *imap.Message) (err error)
- func (c *Client) Subscribe(name string) (err error)
- func (c *Client) SupportsAuth(mech string) bool
- func (c *Client) SupportsStartTLS() bool
- func (c *Client) UidCopy(seqset *imap.SeqSet, dest string) (err error)
- func (c *Client) UidFetch(seqset *imap.SeqSet, items []string, ch chan *imap.Message) (err error)
- func (c *Client) UidSearch(criteria *imap.SearchCriteria) (uids []uint32, err error)
- func (c *Client) UidStore(seqset *imap.SeqSet, item string, value interface{}, ch chan *imap.Message) (err error)
- func (c *Client) Unsubscribe(name string) (err error)
- func (c *Client) Upgrade(upgrader imap.ConnUpgrader) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrAlreadyLoggedIn = errors.New("Already logged in") ErrTLSAlreadyEnabled = errors.New("TLS is already enabled") ErrLoginDisabled = errors.New("Login is disabled in current state") )
var ErrAlreadyLoggedOut = errors.New("Already logged out")
var ErrNoMailboxSelected = errors.New("No mailbox selected")
var ErrNotLoggedIn = errors.New("Not logged in")
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 // ErrorLog specifies an optional logger for errors accepting // connections and unexpected behavior from handlers. // If nil, logging goes to os.Stderr via the log package's // standard logger. ErrorLog *log.Logger // contains filtered or unexported fields }
An IMAP client.
func (*Client) Append ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Copies the specified message(s) to the end of the specified destination mailbox.
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 ¶
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 ¶
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) List ¶
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) LoggedOut ¶
func (c *Client) LoggedOut() <-chan struct{}
LoggedOut returns a channel which is closed when the connection to the server is closed.
func (*Client) Login ¶
Identifies the client to the server and carries the plaintext password authenticating this user.
func (*Client) Lsub ¶
Returns a subset of names from the set of names that the user has declared as being "active" or "subscribed".
func (*Client) Noop ¶
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) Search ¶
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 ¶
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 ¶
If the connection to the IMAP server isn't secure, starts TLS negociation.
This function also resets c.Caps because capabilities change when TLS is enabled.
func (*Client) Status ¶
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 ¶
Adds the specified mailbox name to the server's set of "active" or "subscribed" mailboxes.
func (*Client) SupportsAuth ¶
Check if the server supports a given authentication mechanism.
func (*Client) SupportsStartTLS ¶
Check if the server supports STARTTLS.
func (*Client) UidCopy ¶
Identical to Copy, but seqset is interpreted as containing unique identifiers instead of message sequence numbers.
func (*Client) UidFetch ¶
Identical to Fetch, but seqset is interpreted as containing unique identifiers instead of message sequence numbers.
func (*Client) UidSearch ¶
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 ¶
Removes the specified mailbox name from the server's set of "active" or "subscribed" mailboxes.