Documentation ¶
Index ¶
- Variables
- func AddMailbox(conf *config.AccountData, opts *AddMailboxOpts) error
- func DelMailbox(conf *config.AccountData, opts *DelMailboxOpts) error
- func DelMessage(conf *config.AccountData, opts *DelMessageOpts) error
- func FetchMessages(conf *config.AccountData, opts *FetchOpts) ([]*imap.Message, error)
- func FormatAddress(addr *imap.Address) string
- func FormatAddrlist(addrs []*imap.Address) string
- func FormatHeader(envelope *imap.Envelope) string
- func ListMailboxes(conf *config.AccountData, opts *ListMailboxesOpts) ([]*imap.MailboxInfo, error)
- func ListMessages(conf *config.AccountData, opts *ListMessagesOpts) ([]*imap.Message, error)
- func ListSubscriptions(conf *config.AccountData, opts *ListSubsOpts) ([]string, error)
- func PutMessage(conf *config.AccountData, opts *PutMessageOpts) error
- func SetFlags(conf *config.AccountData, opts *SetFlagsOpts) error
- type AddMailboxOpts
- type DelMailboxOpts
- type DelMessageOpts
- type FetchOpts
- type IMAPConnection
- func (conn *IMAPConnection) AddMailbox(opts *AddMailboxOpts) error
- func (c *IMAPConnection) Close()
- func (conn *IMAPConnection) DelMailbox(opts *DelMailboxOpts) error
- func (conn *IMAPConnection) DelMessage(opts *DelMessageOpts) error
- func (conn *IMAPConnection) FetchMessages(opts *FetchOpts) ([]*imap.Message, error)
- func (conn *IMAPConnection) GetMailboxStatus(name string) (*imap.MailboxStatus, error)
- func (conn *IMAPConnection) ListMailboxes(opts *ListMailboxesOpts) ([]*imap.MailboxInfo, error)
- func (conn *IMAPConnection) ListMessages(opts *ListMessagesOpts) ([]*imap.Message, error)
- func (conn *IMAPConnection) ListSubscriptions(opts *ListSubsOpts) ([]string, error)
- func (conn *IMAPConnection) PutMessage(opts *PutMessageOpts) error
- func (conn *IMAPConnection) SetFlags(opts *SetFlagsOpts) error
- func (c *IMAPConnection) Start(debug bool) error
- func (conn *IMAPConnection) StreamMessages(done chan error, opts *FetchOpts) (chan *imap.Message, error)
- func (c *IMAPConnection) WithLogger(logger imap.Logger)
- func (c *IMAPConnection) WithProxy(proxyUri *url.URL) error
- func (c *IMAPConnection) WithTimeout(timeout time.Duration)
- type ListMailboxesOpts
- type ListMessagesOpts
- type ListSubsOpts
- type PutMessageOpts
- type SetFlagsOpts
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyMailbox = errors.New("Empty mailbox")
var ErrUnencrypted = errors.New("the connection is unencrypted")
Functions ¶
func AddMailbox ¶
func AddMailbox(conf *config.AccountData, opts *AddMailboxOpts) error
AddMailbox adds a mailbox in the server associated with the given account.
func DelMailbox ¶
func DelMailbox(conf *config.AccountData, opts *DelMailboxOpts) error
DelMailbox deletes the given mailbox from the server.
func DelMessage ¶
func DelMessage(conf *config.AccountData, opts *DelMessageOpts) error
DelMessage sets all the given messages' Deleted flag and then callse Expunge, therefore also removing all the other messages previously marked with the Deleted flag.
func FetchMessages ¶
func FetchMessages(conf *config.AccountData, opts *FetchOpts) ([]*imap.Message, error)
FetchMessages given a list of message identifiers, returns a list of imap.Message. This may contain either the header, the body or both, if requested with the provided FetchOpts.
func FormatAddress ¶
func FormatAddress(addr *imap.Address) string
func FormatAddrlist ¶
func FormatAddrlist(addrs []*imap.Address) string
func FormatHeader ¶
func FormatHeader(envelope *imap.Envelope) string
func ListMailboxes ¶
func ListMailboxes(conf *config.AccountData, opts *ListMailboxesOpts) ([]*imap.MailboxInfo, error)
ListMailboxes returns all the mailboxes on the server. If a reference or a mailbox pattern are provided, they are given to the server and by it used to filter the returned mailboxes.
func ListMessages ¶
func ListMessages(conf *config.AccountData, opts *ListMessagesOpts) ([]*imap.Message, error)
ListMessages returns the list of message metadata. It honors the provided limit, starting from the most recent message. a Limit of 0 means no limit at all.
func ListSubscriptions ¶
func ListSubscriptions(conf *config.AccountData, opts *ListSubsOpts) ([]string, error)
ListSubscriptions returns the subscriptions that match the given MailboxPattern. If a Reference is provided, it is passed to the server as-is. If no MailboxPattern is provided it defaults to "*".
func PutMessage ¶
func PutMessage(conf *config.AccountData, opts *PutMessageOpts) error
PutMessage adds a given message in the given mailbox on the server.
func SetFlags ¶
func SetFlags(conf *config.AccountData, opts *SetFlagsOpts) error
SetFlags changes the flags on the specified message in the specified mailbox. First it adds the new flags set, then in removes the flags explicitly unset. Unfortunately, this operation is not atomic.
Types ¶
type AddMailboxOpts ¶
type DelMailboxOpts ¶
type DelMessageOpts ¶
type FetchOpts ¶
type IMAPConnection ¶
type IMAPConnection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(conf *config.AccountData) (*IMAPConnection, error)
NewConnection instantiates a new IMAPConnection. It has to be provided with the config.AccountData necessary to establish an authenticated communication with the server.
func (*IMAPConnection) AddMailbox ¶
func (conn *IMAPConnection) AddMailbox(opts *AddMailboxOpts) error
AddMailbox adds a mailbox in the server associated with the given account.
func (*IMAPConnection) Close ¶
func (c *IMAPConnection) Close()
Close logs out from the server and closes the connection.
func (*IMAPConnection) DelMailbox ¶
func (conn *IMAPConnection) DelMailbox(opts *DelMailboxOpts) error
DelMailbox deletes the given mailbox from the server.
func (*IMAPConnection) DelMessage ¶
func (conn *IMAPConnection) DelMessage(opts *DelMessageOpts) error
DelMessage sets all the given messages' Deleted flag and then calls Expunge, therefore also removing all the other messages previously marked with the Deleted flag.
func (*IMAPConnection) FetchMessages ¶
func (conn *IMAPConnection) FetchMessages(opts *FetchOpts) ([]*imap.Message, error)
FetchMessages given a list of message identifiers, returns a list of imap.Message. This may contain either the header, the body or both, if requested with the provided FetchOpts.
func (*IMAPConnection) GetMailboxStatus ¶
func (conn *IMAPConnection) GetMailboxStatus(name string) (*imap.MailboxStatus, error)
func (*IMAPConnection) ListMailboxes ¶
func (conn *IMAPConnection) ListMailboxes(opts *ListMailboxesOpts) ([]*imap.MailboxInfo, error)
ListMailboxes returns all the mailboxes on the server. If a reference or a mailbox pattern are provided, they are given to the server and by it used to filter the returned mailboxes.
func (*IMAPConnection) ListMessages ¶
func (conn *IMAPConnection) ListMessages(opts *ListMessagesOpts) ([]*imap.Message, error)
ListMessages returns the list of message metadata. It honors the provided limit, starting from the most recent message. a Limit of 0 means no limit at all.
func (*IMAPConnection) ListSubscriptions ¶
func (conn *IMAPConnection) ListSubscriptions(opts *ListSubsOpts) ([]string, error)
ListSubscriptions returns the subscriptions that match the given MailboxPattern. If a Reference is provided, it is passed to the server as-is. If no MailboxPattern is provided it defaults to "*".
func (*IMAPConnection) PutMessage ¶
func (conn *IMAPConnection) PutMessage(opts *PutMessageOpts) error
PutMessage adds a given message in the given mailbox on the server.
func (*IMAPConnection) SetFlags ¶
func (conn *IMAPConnection) SetFlags(opts *SetFlagsOpts) error
SetFlags changes the flags on the specified message in the specified mailbox. First it adds the new flags set, then in removes the flags explicitly unset. Unfortunately, this operation is not atomic.
func (*IMAPConnection) Start ¶
func (c *IMAPConnection) Start(debug bool) error
Start begins a connection with the server. It does not allow for unencrypted communications at the moment. The boolean parameter enables or disables verbose logging of the connection communication.
func (*IMAPConnection) StreamMessages ¶
func (conn *IMAPConnection) StreamMessages(done chan error, opts *FetchOpts) (chan *imap.Message, error)
StreamMessages returns the channels over which are streamed the messages and the completion signal (or errors, if any).
func (*IMAPConnection) WithLogger ¶
func (c *IMAPConnection) WithLogger(logger imap.Logger)
WithLogger returns the same connection with a new logger instead of the default (that logs to os.Stderr).
func (*IMAPConnection) WithTimeout ¶
func (c *IMAPConnection) WithTimeout(timeout time.Duration)
WithTimeout sets a timeout on the operations of the underlying IMAP connection.
type ListMailboxesOpts ¶
type ListMessagesOpts ¶
type ListSubsOpts ¶
type PutMessageOpts ¶
type SetFlagsOpts ¶
type SetFlagsOpts struct { Mailbox string MessageSeq *imap.SeqSet ByUid bool Flags *flags.FlagsStatus Debug bool }