imaputils

package
v0.0.0-...-900104f Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyMailbox = errors.New("Empty mailbox")
View Source
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 AddMailboxOpts struct {
	Name  string
	Debug bool
}

type DelMailboxOpts

type DelMailboxOpts struct {
	Name  string
	Debug bool
}

type DelMessageOpts

type DelMessageOpts struct {
	Debug      bool
	Mailbox    string
	MessageSeq *imap.SeqSet
	ByUid      bool
}

type FetchOpts

type FetchOpts struct {
	Mailbox     string
	MessageSeq  *imap.SeqSet
	ByUid       bool
	WithHeaders bool
	WithBody    bool
	WithEntire  bool
	WithFlags   bool
	Peek        bool
	Debug       bool
}

func (*FetchOpts) String

func (o *FetchOpts) String() string

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) WithProxy

func (c *IMAPConnection) WithProxy(proxyUri *url.URL) error

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 ListMailboxesOpts struct {
	MailboxPattern string
	Reference      string
	Debug          bool
}

type ListMessagesOpts

type ListMessagesOpts struct {
	Mailbox string
	Limit   uint32
	Debug   bool
}

type ListSubsOpts

type ListSubsOpts struct {
	Debug          bool
	MailboxPattern string
	Reference      string
}

type PutMessageOpts

type PutMessageOpts struct {
	Debug   bool
	Mailbox string
	Body    *bytes.Buffer
	Flags   []string
	Time    time.Time
}

type SetFlagsOpts

type SetFlagsOpts struct {
	Mailbox    string
	MessageSeq *imap.SeqSet
	ByUid      bool
	Flags      *flags.FlagsStatus
	Debug      bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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