imap

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttrNoSelect    = `\Noselect`
	AttrNoInferiors = `\Noinferiors`
	AttrMarked      = `\Marked`
	AttrUnmarked    = `\Unmarked`

	// Special Use attributes as defined in RFC-6154.
	AttrAll     = `\All`
	AttrArchive = `\Archive`
	AttrDrafts  = `\Drafts`
	AttrFlagged = `\Flagged`
	AttrJunk    = `\Junk`
	AttrSent    = `\Sent`
	AttrTrash   = `\Trash`
)
View Source
const (
	FlagSeen     = `\Seen`
	FlagAnswered = `\Answered`
	FlagFlagged  = `\Flagged`
	FlagDeleted  = `\Deleted`
	FlagDraft    = `\Draft`
	FlagRecent   = `\Recent` // Read-only!.
)
View Source
const (
	FlagSeenLowerCase     = `\seen`
	FlagAnsweredLowerCase = `\answered`
	FlagFlaggedLowerCase  = `\flagged`
	FlagDeletedLowerCase  = `\deleted`
	FlagDraftLowerCase    = `\draft`
	FlagRecentLowerCase   = `\recent` // Read-only!.
)
View Source
const (
	IDKeyName             = "name"
	IDKeyVersion          = "version"
	IDKeyOS               = "os"
	IdKeyOSVersion        = "os-version"
	IDKeyVendor           = "vendor"
	IDKeySupportURL       = "support-url"
	IDKeyAddress          = "address"
	IDKeyDate             = "date"
	IDKeyCommand          = "command"
	IDKeyArguments        = "arguments"
	IDKeyEnvironment      = "environment"
	IMAPIDConnMetadataKey = "rfc2971-id"
)
View Source
const (
	StatusMessages    = `MESSAGES`
	StatusRecent      = `RECENT`
	StatusUIDNext     = `UIDNEXT`
	StatusUIDValidity = `UIDVALIDITY`
	StatusUnseen      = `UNSEEN`
)
View Source
const Inbox = "INBOX"

Variables

This section is empty.

Functions

func Envelope

func Envelope(header *rfc822.Header) (string, error)

func IsCapabilityAvailableBeforeAuth added in v0.12.0

func IsCapabilityAvailableBeforeAuth(c Capability) bool

func NewContextWithIMAPID added in v0.8.0

func NewContextWithIMAPID(ctx context.Context, id IMAPID) context.Context

func ShortID added in v0.17.0

func ShortID(id string) string

ShortID return a string containing a short version of the given ID. Use only for debug display.

func Structure

func Structure(section *rfc822.Section) (string, string, error)

Types

type Capability

type Capability string
const (
	IMAP4rev1 Capability = `IMAP4rev1`
	StartTLS  Capability = `STARTTLS`
	IDLE      Capability = `IDLE`
	UNSELECT  Capability = `UNSELECT`
	UIDPLUS   Capability = `UIDPLUS`
	MOVE      Capability = `MOVE`
	ID        Capability = `ID`
)

type EpochUIDValidityGenerator added in v0.15.0

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

func DefaultEpochUIDValidityGenerator added in v0.15.0

func DefaultEpochUIDValidityGenerator() *EpochUIDValidityGenerator

func NewEpochUIDValidityGenerator added in v0.15.0

func NewEpochUIDValidityGenerator(epochStart time.Time) *EpochUIDValidityGenerator

func (*EpochUIDValidityGenerator) Generate added in v0.15.0

func (e *EpochUIDValidityGenerator) Generate() (UID, error)

type Field

type Field struct {
	Key, Value string
}

type FixedUIDValidityGenerator added in v0.15.0

type FixedUIDValidityGenerator struct {
	Value UID
}

func NewFixedUIDValidityGenerator added in v0.15.0

func NewFixedUIDValidityGenerator(value UID) *FixedUIDValidityGenerator

func (FixedUIDValidityGenerator) Generate added in v0.15.0

func (f FixedUIDValidityGenerator) Generate() (UID, error)

type FlagSet

type FlagSet map[string]string

FlagSet represents a set of IMAP flags. Flags are case-insensitive and no duplicates are allowed.

func NewFlagSet

func NewFlagSet(flags ...string) FlagSet

NewFlagSet creates a flag set containing the specified flags.

func NewFlagSetFromSlice

func NewFlagSetFromSlice(flags []string) FlagSet

NewFlagSetFromSlice creates a flag set containing the flags from a slice.

func NewFlagSetWithCapacity added in v0.12.0

func NewFlagSetWithCapacity(capacity int) FlagSet

func (FlagSet) Add

func (fs FlagSet) Add(flags ...string) FlagSet

Add adds new flags to the flag set. The function returns false iff no flags was actually added because they're already in the set. The case of existing elements is preserved.

func (FlagSet) AddFlagSet

func (fs FlagSet) AddFlagSet(set FlagSet) FlagSet

func (FlagSet) AddFlagSetToSelf added in v0.12.0

func (fs FlagSet) AddFlagSetToSelf(set FlagSet)

func (FlagSet) AddToSelf added in v0.12.0

func (fs FlagSet) AddToSelf(flags ...string)

func (FlagSet) Clone added in v0.12.0

func (fs FlagSet) Clone() FlagSet

Clone creates a hard copy of the flag set.

func (FlagSet) Contains

func (fs FlagSet) Contains(flag string) bool

Contains returns true if and only if the flag is in the set.

func (FlagSet) ContainsAll

func (fs FlagSet) ContainsAll(flags ...string) bool

ContainsAll returns true if and only if all of the flags are in the set.

func (FlagSet) ContainsAny

func (fs FlagSet) ContainsAny(flags ...string) bool

ContainsAny returns true if and only if any of the flags are in the set.

func (FlagSet) ContainsUnchecked added in v0.12.0

func (fs FlagSet) ContainsUnchecked(flag string) bool

ContainsUnchecked returns true if and only if the flag is in the set. The flag is not converted to lower case. This is useful for cases where we need to check flags in bulk.

func (FlagSet) Equals

func (fs FlagSet) Equals(otherFs FlagSet) bool

Equals returns true if and only if the two sets are equal (same number of elements and each element of fs is also in otherFs).

func (FlagSet) Len

func (fs FlagSet) Len() int

Len returns the number of flags in the flag set.

func (FlagSet) Remove

func (fs FlagSet) Remove(flags ...string) FlagSet

func (FlagSet) RemoveFlagSet

func (fs FlagSet) RemoveFlagSet(set FlagSet) FlagSet

func (FlagSet) RemoveFlagSetFromSelf added in v0.12.0

func (fs FlagSet) RemoveFlagSetFromSelf(set FlagSet)

func (FlagSet) RemoveFromSelf added in v0.12.0

func (fs FlagSet) RemoveFromSelf(flags ...string)

func (FlagSet) Set

func (fs FlagSet) Set(flag string, on bool) FlagSet

Set ensures the flagset either contains or does not contain the given flag.

func (FlagSet) SetOnSelf added in v0.12.0

func (fs FlagSet) SetOnSelf(flag string, on bool)

SetOnSelf ensures the flagset either contains or does not contain the given flag.

func (FlagSet) ToSlice

func (fs FlagSet) ToSlice() []string

ToSlice Returns the list of flags in the set as a sorted string slice. The returned list is a hard copy of the internal slice to avoid direct modifications of the FlagSet value that would break the uniqueness and case insensitivity rules.

func (FlagSet) ToSliceUnsorted added in v0.17.0

func (fs FlagSet) ToSliceUnsorted() []string

ToSliceUnsorted is the same as ToSlice, but does not sort the returned value.

type Header []Field

type IMAPID added in v0.12.0

type IMAPID struct {
	Name        string
	Version     string
	OS          string
	OSVersion   string
	Vendor      string
	SupportURL  string
	Address     string
	Date        string
	Command     string
	Arguments   string
	Environment string
	Other       map[string]string
}

IMAPID represents the RFC 2971 IMAP IMAPID Extension. This information can be retrieved by the connector at the context level. To do so please use the provided GetIMAPIDFromContext() function.

func GetIMAPIDFromContext added in v0.8.0

func GetIMAPIDFromContext(ctx context.Context) (IMAPID, bool)

func NewIMAPID added in v0.12.0

func NewIMAPID() IMAPID

func NewIMAPIDFromKeyMap added in v0.8.0

func NewIMAPIDFromKeyMap(m map[string]string) IMAPID

func NewIMAPIDFromVersionInfo added in v0.8.0

func NewIMAPIDFromVersionInfo(info version.Info) IMAPID

func (*IMAPID) String added in v0.12.0

func (id *IMAPID) String() string

type IncrementalUIDValidityGenerator added in v0.15.0

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

func NewIncrementalUIDValidityGenerator added in v0.15.0

func NewIncrementalUIDValidityGenerator() *IncrementalUIDValidityGenerator

func (*IncrementalUIDValidityGenerator) Generate added in v0.15.0

func (i *IncrementalUIDValidityGenerator) Generate() (UID, error)

func (*IncrementalUIDValidityGenerator) GetValue added in v0.15.0

func (i *IncrementalUIDValidityGenerator) GetValue() UID

type InternalMailboxID added in v0.11.0

type InternalMailboxID uint64

func (InternalMailboxID) ShortID added in v0.11.0

func (i InternalMailboxID) ShortID() string

func (InternalMailboxID) String added in v0.12.0

func (i InternalMailboxID) String() string

type InternalMessageID added in v0.11.0

type InternalMessageID struct {
	uuid.UUID
}

func InternalMessageIDFromString added in v0.12.0

func InternalMessageIDFromString(id string) (InternalMessageID, error)

func NewInternalMessageID added in v0.14.1

func NewInternalMessageID() InternalMessageID

func (InternalMessageID) ShortID added in v0.11.0

func (i InternalMessageID) ShortID() string

func (InternalMessageID) String added in v0.12.0

func (i InternalMessageID) String() string

type Mailbox

type Mailbox struct {
	ID MailboxID

	Name []string

	Flags, PermanentFlags, Attributes FlagSet
}

type MailboxCreated

type MailboxCreated struct {
	Mailbox Mailbox
	// contains filtered or unexported fields
}

func NewMailboxCreated

func NewMailboxCreated(mailbox Mailbox) *MailboxCreated

func (MailboxCreated) Done

func (w MailboxCreated) Done(err error)

func (*MailboxCreated) String

func (u *MailboxCreated) String() string

func (MailboxCreated) Wait

func (w MailboxCreated) Wait() (error, bool)

func (MailboxCreated) WaitContext added in v0.12.0

func (w MailboxCreated) WaitContext(ctx context.Context) (error, bool)

type MailboxDeleted

type MailboxDeleted struct {
	MailboxID MailboxID
	// contains filtered or unexported fields
}

func NewMailboxDeleted

func NewMailboxDeleted(mailboxID MailboxID) *MailboxDeleted

func (MailboxDeleted) Done

func (w MailboxDeleted) Done(err error)

func (*MailboxDeleted) String

func (u *MailboxDeleted) String() string

func (MailboxDeleted) Wait

func (w MailboxDeleted) Wait() (error, bool)

func (MailboxDeleted) WaitContext added in v0.12.0

func (w MailboxDeleted) WaitContext(ctx context.Context) (error, bool)

type MailboxID added in v0.13.0

type MailboxID string

func (MailboxID) ShortID added in v0.13.0

func (l MailboxID) ShortID() string

type MailboxIDChanged

type MailboxIDChanged struct {
	InternalID InternalMailboxID
	RemoteID   MailboxID
	// contains filtered or unexported fields
}

func NewMailboxIDChanged

func NewMailboxIDChanged(internalID InternalMailboxID, remoteID MailboxID) *MailboxIDChanged

func (MailboxIDChanged) Done

func (w MailboxIDChanged) Done(err error)

func (*MailboxIDChanged) String

func (u *MailboxIDChanged) String() string

func (MailboxIDChanged) Wait

func (w MailboxIDChanged) Wait() (error, bool)

func (MailboxIDChanged) WaitContext added in v0.12.0

func (w MailboxIDChanged) WaitContext(ctx context.Context) (error, bool)

type MailboxUpdated

type MailboxUpdated struct {
	MailboxID   MailboxID
	MailboxName []string
	// contains filtered or unexported fields
}

func NewMailboxUpdated

func NewMailboxUpdated(mailboxID MailboxID, mailboxName []string) *MailboxUpdated

func (MailboxUpdated) Done

func (w MailboxUpdated) Done(err error)

func (*MailboxUpdated) String

func (u *MailboxUpdated) String() string

func (MailboxUpdated) Wait

func (w MailboxUpdated) Wait() (error, bool)

func (MailboxUpdated) WaitContext added in v0.12.0

func (w MailboxUpdated) WaitContext(ctx context.Context) (error, bool)

type MailboxVisibility added in v0.15.0

type MailboxVisibility int
const (
	Hidden MailboxVisibility = iota
	Visible
	HiddenIfEmpty
)

type Message

type Message struct {
	ID    MessageID
	Flags FlagSet
	Date  time.Time
}

func (*Message) HasFlag

func (m *Message) HasFlag(wantFlag string) bool

type MessageCreated

type MessageCreated struct {
	Message       Message
	Literal       []byte
	MailboxIDs    []MailboxID
	ParsedMessage *ParsedMessage
}

type MessageDeleted added in v0.8.1

type MessageDeleted struct {
	MessageID MessageID
	// contains filtered or unexported fields
}

func NewMessagesDeleted added in v0.8.1

func NewMessagesDeleted(messageID MessageID) *MessageDeleted

func (MessageDeleted) Done added in v0.8.1

func (w MessageDeleted) Done(err error)

func (*MessageDeleted) String added in v0.8.1

func (u *MessageDeleted) String() string

func (MessageDeleted) Wait added in v0.8.1

func (w MessageDeleted) Wait() (error, bool)

func (MessageDeleted) WaitContext added in v0.12.0

func (w MessageDeleted) WaitContext(ctx context.Context) (error, bool)

type MessageFlagsUpdated added in v0.12.0

type MessageFlagsUpdated struct {
	MessageID MessageID
	Flags     FlagSet
	// contains filtered or unexported fields
}

func NewMessageFlagsUpdated added in v0.12.0

func NewMessageFlagsUpdated(messageID MessageID, flags FlagSet) *MessageFlagsUpdated

func (MessageFlagsUpdated) Done added in v0.12.0

func (w MessageFlagsUpdated) Done(err error)

func (*MessageFlagsUpdated) String added in v0.12.0

func (u *MessageFlagsUpdated) String() string

func (MessageFlagsUpdated) Wait added in v0.12.0

func (w MessageFlagsUpdated) Wait() (error, bool)

func (MessageFlagsUpdated) WaitContext added in v0.12.0

func (w MessageFlagsUpdated) WaitContext(ctx context.Context) (error, bool)

type MessageID added in v0.11.0

type MessageID string

func (MessageID) ShortID added in v0.11.0

func (m MessageID) ShortID() string

type MessageIDChanged

type MessageIDChanged struct {
	InternalID InternalMessageID
	RemoteID   MessageID
	// contains filtered or unexported fields
}

func NewMessageIDChanged

func NewMessageIDChanged(internalID InternalMessageID, remoteID MessageID) *MessageIDChanged

func (MessageIDChanged) Done

func (w MessageIDChanged) Done(err error)

func (*MessageIDChanged) String

func (u *MessageIDChanged) String() string

func (MessageIDChanged) Wait

func (w MessageIDChanged) Wait() (error, bool)

func (MessageIDChanged) WaitContext added in v0.12.0

func (w MessageIDChanged) WaitContext(ctx context.Context) (error, bool)

type MessageMailboxesUpdated added in v0.13.0

type MessageMailboxesUpdated struct {
	MessageID  MessageID
	MailboxIDs []MailboxID
	Flags      FlagSet
	// contains filtered or unexported fields
}

func NewMessageMailboxesUpdated added in v0.13.0

func NewMessageMailboxesUpdated(messageID MessageID, mailboxIDs []MailboxID, flags FlagSet) *MessageMailboxesUpdated

func (MessageMailboxesUpdated) Done added in v0.13.0

func (w MessageMailboxesUpdated) Done(err error)

func (*MessageMailboxesUpdated) String added in v0.13.0

func (u *MessageMailboxesUpdated) String() string

func (MessageMailboxesUpdated) Wait added in v0.13.0

func (w MessageMailboxesUpdated) Wait() (error, bool)

func (MessageMailboxesUpdated) WaitContext added in v0.13.0

func (w MessageMailboxesUpdated) WaitContext(ctx context.Context) (error, bool)

type MessageUpdated

type MessageUpdated struct {
	Message       Message
	Literal       []byte
	MailboxIDs    []MailboxID
	ParsedMessage *ParsedMessage
	AllowCreate   bool
	// contains filtered or unexported fields
}

MessageUpdated replaces the previous behavior of MessageDelete followed by MessageCreate. If the message does exist, it is updated. If the message does not exist, it can optionally be created. Furthermore, it guarantees that the operation is executed atomically.

func NewMessageUpdated

func NewMessageUpdated(
	message Message,
	literal []byte,
	mailboxIDs []MailboxID,
	parsedMessage *ParsedMessage,
	allowCreate bool,
) *MessageUpdated

func (MessageUpdated) Done

func (w MessageUpdated) Done(err error)

func (*MessageUpdated) String

func (u *MessageUpdated) String() string

func (MessageUpdated) Wait

func (w MessageUpdated) Wait() (error, bool)

func (MessageUpdated) WaitContext added in v0.14.0

func (w MessageUpdated) WaitContext(ctx context.Context) (error, bool)

type MessagesCreated added in v0.7.0

type MessagesCreated struct {
	Messages []*MessageCreated

	// IgnoreUnknownMailboxIDs will allow message creation when one or more MailboxIDs are not yet known when set to true.
	IgnoreUnknownMailboxIDs bool
	// contains filtered or unexported fields
}

func NewMessagesCreated added in v0.7.0

func NewMessagesCreated(ignoreUnknownMailboxIDs bool, updates ...*MessageCreated) *MessagesCreated

func (MessagesCreated) Done added in v0.7.0

func (w MessagesCreated) Done(err error)

func (*MessagesCreated) String added in v0.7.0

func (u *MessagesCreated) String() string

func (MessagesCreated) Wait added in v0.7.0

func (w MessagesCreated) Wait() (error, bool)

func (MessagesCreated) WaitContext added in v0.12.0

func (w MessagesCreated) WaitContext(ctx context.Context) (error, bool)

type Noop added in v0.12.0

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

func NewNoop added in v0.12.0

func NewNoop() *Noop

func (Noop) Done added in v0.12.0

func (w Noop) Done(err error)

func (*Noop) String added in v0.12.0

func (u *Noop) String() string

func (Noop) Wait added in v0.12.0

func (w Noop) Wait() (error, bool)

func (Noop) WaitContext added in v0.12.0

func (w Noop) WaitContext(ctx context.Context) (error, bool)

type ParsedMessage added in v0.12.0

type ParsedMessage struct {
	Body      string
	Structure string
	Envelope  string
}

func NewParsedMessage added in v0.12.0

func NewParsedMessage(literal []byte) (*ParsedMessage, error)

type SeqID added in v0.12.0

type SeqID uint32

type SeqSet

type SeqSet []SeqVal

func NewSeqSet

func NewSeqSet(set []SeqID) SeqSet

func NewSeqSetFromUID added in v0.12.0

func NewSeqSetFromUID(set []UID) SeqSet

func (SeqSet) String

func (set SeqSet) String() string

type SeqVal

type SeqVal struct {
	Begin, End SeqID
}

func (SeqVal) String

func (seqval SeqVal) String() string

type UID added in v0.12.0

type UID uint32

func (UID) Add added in v0.12.0

func (u UID) Add(v uint32) UID

type UIDValidityBumped added in v0.14.0

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

func NewUIDValidityBumped added in v0.14.0

func NewUIDValidityBumped() *UIDValidityBumped

func (UIDValidityBumped) Done added in v0.14.0

func (w UIDValidityBumped) Done(err error)

func (*UIDValidityBumped) String added in v0.14.0

func (u *UIDValidityBumped) String() string

func (UIDValidityBumped) Wait added in v0.14.0

func (w UIDValidityBumped) Wait() (error, bool)

func (UIDValidityBumped) WaitContext added in v0.14.0

func (w UIDValidityBumped) WaitContext(ctx context.Context) (error, bool)

type UIDValidityGenerator added in v0.15.0

type UIDValidityGenerator interface {
	Generate() (UID, error)
}

type Update

type Update interface {
	Waiter

	String() string
	// contains filtered or unexported methods
}

type Waiter

type Waiter interface {
	// Wait waits until the update has been marked as done.
	Wait() (error, bool)

	// WaitContext waits until the update has been marked as done or the context is cancelled.
	WaitContext(context.Context) (error, bool)

	// Done marks the update as done and report an error (if any).
	Done(error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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