imap

package module
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 8 Imported by: 0

README

go-imap

builds.sr.ht status Go Reference

An IMAP4rev2 library for Go.

Note This is the README for go-imap v2. This new major version is still in development. For go-imap v1, see the v1 branch.

Usage

To add go-imap to your project, run:

go get github.com/emersion/go-imap/v2

Documentation and examples for the module are available here:

License

MIT

Documentation

Overview

Package imap implements IMAP4rev2.

IMAP4rev2 is defined in RFC 9051.

This package contains types and functions common to both the client and server. See the imapclient and imapserver sub-packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSearchRes

func IsSearchRes(numSet NumSet) bool

IsSearchRes checks whether a sequence set is a reference to the last SEARCH result. See SearchRes.

Types

type Address

type Address struct {
	Name    string
	Mailbox string
	Host    string
}

Address represents a sender or recipient of a message.

func (*Address) Addr

func (addr *Address) Addr() string

Addr returns the e-mail address in the form "foo@example.org".

If the address is a start or end of group, the empty string is returned.

func (*Address) IsGroupEnd

func (addr *Address) IsGroupEnd() bool

IsGroupEnd returns true if this address is a end of group marker.

func (*Address) IsGroupStart

func (addr *Address) IsGroupStart() bool

IsGroupStart returns true if this address is a start of group marker.

In that case, Mailbox contains the group name phrase.

type AppendData

type AppendData struct {
	// requires UIDPLUS or IMAP4rev2
	UID         UID
	UIDValidity uint32
}

AppendData is the data returned by an APPEND command.

type AppendOptions

type AppendOptions struct {
	Flags []Flag
	Time  time.Time
}

AppendOptions contains options for the APPEND command.

type BodyStructure

type BodyStructure interface {
	// MediaType returns the MIME type of this body structure, e.g. "text/plain".
	MediaType() string
	// Walk walks the body structure tree, calling f for each part in the tree,
	// including bs itself. The parts are visited in DFS pre-order.
	Walk(f BodyStructureWalkFunc)
	// Disposition returns the body structure disposition, if available.
	Disposition() *BodyStructureDisposition
	// contains filtered or unexported methods
}

BodyStructure describes the body structure of a message.

A BodyStructure value is either a *BodyStructureSinglePart or a *BodyStructureMultiPart.

type BodyStructureDisposition

type BodyStructureDisposition struct {
	Value  string
	Params map[string]string
}

BodyStructureDisposition describes the content disposition of a part (specified in the Content-Disposition header field).

type BodyStructureMessageRFC822

type BodyStructureMessageRFC822 struct {
	Envelope      *Envelope
	BodyStructure BodyStructure
	NumLines      int64
}

BodyStructureMessageRFC822 contains metadata specific to RFC 822 parts for BodyStructureSinglePart.

type BodyStructureMultiPart

type BodyStructureMultiPart struct {
	Children []BodyStructure
	Subtype  string

	Extended *BodyStructureMultiPartExt
}

BodyStructureMultiPart is a body structure with multiple parts.

func (*BodyStructureMultiPart) Disposition

func (*BodyStructureMultiPart) MediaType

func (bs *BodyStructureMultiPart) MediaType() string

func (*BodyStructureMultiPart) Walk

type BodyStructureMultiPartExt

type BodyStructureMultiPartExt struct {
	Params      map[string]string
	Disposition *BodyStructureDisposition
	Language    []string
	Location    string
}

BodyStructureMultiPartExt contains extended body structure data for BodyStructureMultiPart.

type BodyStructureSinglePart

type BodyStructureSinglePart struct {
	Type, Subtype string
	Params        map[string]string
	ID            string
	Description   string
	Encoding      string
	Size          uint32

	MessageRFC822 *BodyStructureMessageRFC822 // only for "message/rfc822"
	Text          *BodyStructureText          // only for "text/*"
	Extended      *BodyStructureSinglePartExt
}

BodyStructureSinglePart is a body structure with a single part.

func (*BodyStructureSinglePart) Disposition

func (*BodyStructureSinglePart) Filename

func (bs *BodyStructureSinglePart) Filename() string

Filename decodes the body structure's filename, if any.

func (*BodyStructureSinglePart) MediaType

func (bs *BodyStructureSinglePart) MediaType() string

func (*BodyStructureSinglePart) Walk

type BodyStructureSinglePartExt

type BodyStructureSinglePartExt struct {
	Disposition *BodyStructureDisposition
	Language    []string
	Location    string
}

BodyStructureSinglePartExt contains extended body structure data for BodyStructureSinglePart.

type BodyStructureText

type BodyStructureText struct {
	NumLines int64
}

BodyStructureText contains metadata specific to text parts for BodyStructureSinglePart.

type BodyStructureWalkFunc

type BodyStructureWalkFunc func(path []int, part BodyStructure) (walkChildren bool)

BodyStructureWalkFunc is a function called for each body structure visited by BodyStructure.Walk.

The path argument contains the IMAP part path.

The function should return true to visit all of the part's children or false to skip them.

type Cap

type Cap string

Cap represents an IMAP capability.

const (
	CapIMAP4rev1 Cap = "IMAP4rev1" // RFC 3501
	CapIMAP4rev2 Cap = "IMAP4rev2" // RFC 9051

	CapAuthPlain Cap = "AUTH=PLAIN"

	CapStartTLS      Cap = "STARTTLS"
	CapLoginDisabled Cap = "LOGINDISABLED"

	// Folded in IMAP4rev2
	CapNamespace    Cap = "NAMESPACE"     // RFC 2342
	CapUnselect     Cap = "UNSELECT"      // RFC 3691
	CapUIDPlus      Cap = "UIDPLUS"       // RFC 4315
	CapESearch      Cap = "ESEARCH"       // RFC 4731
	CapSearchRes    Cap = "SEARCHRES"     // RFC 5182
	CapEnable       Cap = "ENABLE"        // RFC 5161
	CapIdle         Cap = "IDLE"          // RFC 2177
	CapSASLIR       Cap = "SASL-IR"       // RFC 4959
	CapListExtended Cap = "LIST-EXTENDED" // RFC 5258
	CapListStatus   Cap = "LIST-STATUS"   // RFC 5819
	CapMove         Cap = "MOVE"          // RFC 6851
	CapLiteralMinus Cap = "LITERAL-"      // RFC 7888
	CapStatusSize   Cap = "STATUS=SIZE"   // RFC 8438

	CapACL              Cap = "ACL"                // RFC 4314
	CapAppendLimit      Cap = "APPENDLIMIT"        // RFC 7889
	CapBinary           Cap = "BINARY"             // RFC 3516
	CapCatenate         Cap = "CATENATE"           // RFC 4469
	CapChildren         Cap = "CHILDREN"           // RFC 3348
	CapCondStore        Cap = "CONDSTORE"          // RFC 7162
	CapConvert          Cap = "CONVERT"            // RFC 5259
	CapCreateSpecialUse Cap = "CREATE-SPECIAL-USE" // RFC 6154
	CapESort            Cap = "ESORT"              // RFC 5267
	CapFilters          Cap = "FILTERS"            // RFC 5466
	CapID               Cap = "ID"                 // RFC 2971
	CapLanguage         Cap = "LANGUAGE"           // RFC 5255
	CapListMyRights     Cap = "LIST-MYRIGHTS"      // RFC 8440
	CapLiteralPlus      Cap = "LITERAL+"           // RFC 7888
	CapLoginReferrals   Cap = "LOGIN-REFERRALS"    // RFC 2221
	CapMailboxReferrals Cap = "MAILBOX-REFERRALS"  // RFC 2193
	CapMetadata         Cap = "METADATA"           // RFC 5464
	CapMetadataServer   Cap = "METADATA-SERVER"    // RFC 5464
	CapMultiAppend      Cap = "MULTIAPPEND"        // RFC 3502
	CapMultiSearch      Cap = "MULTISEARCH"        // RFC 7377
	CapNotify           Cap = "NOTIFY"             // RFC 5465
	CapObjectID         Cap = "OBJECTID"           // RFC 8474
	CapPreview          Cap = "PREVIEW"            // RFC 8970
	CapQResync          Cap = "QRESYNC"            // RFC 7162
	CapQuota            Cap = "QUOTA"              // RFC 9208
	CapQuotaSet         Cap = "QUOTASET"           // RFC 9208
	CapReplace          Cap = "REPLACE"            // RFC 8508
	CapSaveDate         Cap = "SAVEDATE"           // RFC 8514
	CapSearchFuzzy      Cap = "SEARCH=FUZZY"       // RFC 6203
	CapSort             Cap = "SORT"               // RFC 5256
	CapSortDisplay      Cap = "SORT=DISPLAY"       // RFC 5957
	CapSpecialUse       Cap = "SPECIAL-USE"        // RFC 6154
	CapUnauthenticate   Cap = "UNAUTHENTICATE"     // RFC 8437
	CapURLPartial       Cap = "URL-PARTIAL"        // RFC 5550
	CapURLAuth          Cap = "URLAUTH"            // RFC 4467
	CapUTF8Accept       Cap = "UTF8=ACCEPT"        // RFC 6855
	CapUTF8Only         Cap = "UTF8=ONLY"          // RFC 6855
	CapWithin           Cap = "WITHIN"             // RFC 5032
)

Registered capabilities.

See: https://www.iana.org/assignments/imap-capabilities/

func AuthCap

func AuthCap(mechanism string) Cap

AuthCap returns the capability name for an SASL authentication mechanism.

type CapSet

type CapSet map[Cap]struct{}

CapSet is a set of capabilities.

func (CapSet) AppendLimit

func (set CapSet) AppendLimit() (limit *uint32, ok bool)

AppendLimit checks the APPENDLIMIT capability.

If the server supports APPENDLIMIT, ok is true. If the server doesn't have the same upload limit for all mailboxes, limit is nil and per-mailbox limits must be queried via STATUS.

func (CapSet) AuthMechanisms

func (set CapSet) AuthMechanisms() []string

AuthMechanisms returns the list of supported SASL mechanisms for authentication.

func (CapSet) Has

func (set CapSet) Has(c Cap) bool

Has checks whether a capability is supported.

Some capabilities are implied by others, as such Has may return true even if the capability is not in the map.

func (CapSet) QuotaResourceTypes

func (set CapSet) QuotaResourceTypes() []QuotaResourceType

QuotaResourceTypes returns the list of supported QUOTA resource types.

func (CapSet) ThreadAlgorithms

func (set CapSet) ThreadAlgorithms() []ThreadAlgorithm

ThreadAlgorithms returns the list of supported threading algorithms.

type ConnState

type ConnState int

ConnState describes the connection state.

See RFC 9051 section 3.

const (
	ConnStateNone ConnState = iota
	ConnStateNotAuthenticated
	ConnStateAuthenticated
	ConnStateSelected
	ConnStateLogout
)

func (ConnState) String

func (state ConnState) String() string

String implements fmt.Stringer.

type CopyData

type CopyData struct {
	// requires UIDPLUS or IMAP4rev2
	UIDValidity uint32
	SourceUIDs  UIDSet
	DestUIDs    UIDSet
}

CopyData is the data returned by a COPY command.

type CreateOptions

type CreateOptions struct {
	SpecialUse []MailboxAttr // requires CREATE-SPECIAL-USE
}

CreateOptions contains options for the CREATE command.

type Envelope

type Envelope struct {
	Date      time.Time
	Subject   string
	From      []Address
	Sender    []Address
	ReplyTo   []Address
	To        []Address
	Cc        []Address
	Bcc       []Address
	InReplyTo []string
	MessageID string
}

Envelope is the envelope structure of a message.

The subject and addresses are UTF-8 (ie, not in their encoded form). The In-Reply-To and Message-ID values contain message identifiers without angle brackets.

type Error

type Error StatusResponse

Error is an IMAP error caused by a status response.

func (*Error) Error

func (err *Error) Error() string

Error implements the error interface.

type FetchItemBinarySection

type FetchItemBinarySection struct {
	Part    []int
	Partial *SectionPartial
	Peek    bool
}

FetchItemBinarySection is a FETCH BINARY[] data item.

type FetchItemBinarySectionSize

type FetchItemBinarySectionSize struct {
	Part []int
}

FetchItemBinarySectionSize is a FETCH BINARY.SIZE[] data item.

type FetchItemBodySection

type FetchItemBodySection struct {
	Specifier       PartSpecifier
	Part            []int
	HeaderFields    []string
	HeaderFieldsNot []string
	Partial         *SectionPartial
	Peek            bool
}

FetchItemBodySection is a FETCH BODY[] data item.

To fetch the whole body of a message, use the zero FetchItemBodySection:

imap.FetchItemBodySection{}

To fetch only a specific part, use the Part field:

imap.FetchItemBodySection{Part: []int{1, 2, 3}}

To fetch only the header of the message, use the Specifier field:

imap.FetchItemBodySection{Specifier: imap.PartSpecifierHeader}

type FetchItemBodyStructure

type FetchItemBodyStructure struct {
	Extended bool
}

FetchItemBodyStructure contains FETCH options for the body structure.

type FetchOptions

type FetchOptions struct {
	// Fields to fetch
	BodyStructure     *FetchItemBodyStructure
	Envelope          bool
	Flags             bool
	InternalDate      bool
	RFC822Size        bool
	UID               bool
	BodySection       []*FetchItemBodySection
	BinarySection     []*FetchItemBinarySection     // requires IMAP4rev2 or BINARY
	BinarySectionSize []*FetchItemBinarySectionSize // requires IMAP4rev2 or BINARY
	ModSeq            bool                          // requires CONDSTORE

	ChangedSince uint64 // requires CONDSTORE
}

FetchOptions contains options for the FETCH command.

type Flag

type Flag string

Flag is a message flag.

Message flags are defined in RFC 9051 section 2.3.2.

const (
	// System flags
	FlagSeen     Flag = "\\Seen"
	FlagAnswered Flag = "\\Answered"
	FlagFlagged  Flag = "\\Flagged"
	FlagDeleted  Flag = "\\Deleted"
	FlagDraft    Flag = "\\Draft"

	// Widely used flags
	FlagForwarded Flag = "$Forwarded"
	FlagMDNSent   Flag = "$MDNSent" // Message Disposition Notification sent
	FlagJunk      Flag = "$Junk"
	FlagNotJunk   Flag = "$NotJunk"
	FlagPhishing  Flag = "$Phishing"
	FlagImportant Flag = "$Important" // RFC 8457

	// Permanent flags
	FlagWildcard Flag = "\\*"
)

type ListData

type ListData struct {
	Attrs   []MailboxAttr
	Delim   rune
	Mailbox string

	// Extended data
	ChildInfo *ListDataChildInfo
	OldName   string
	Status    *StatusData
}

ListData is the mailbox data returned by a LIST command.

type ListDataChildInfo

type ListDataChildInfo struct {
	Subscribed bool
}

type ListOptions

type ListOptions struct {
	SelectSubscribed     bool
	SelectRemote         bool
	SelectRecursiveMatch bool // requires SelectSubscribed to be set
	SelectSpecialUse     bool // requires SPECIAL-USE

	ReturnSubscribed bool
	ReturnChildren   bool
	ReturnStatus     *StatusOptions // requires IMAP4rev2 or LIST-STATUS
	ReturnSpecialUse bool           // requires SPECIAL-USE
}

ListOptions contains options for the LIST command.

type LiteralReader

type LiteralReader interface {
	io.Reader
	Size() int64
}

LiteralReader is a reader for IMAP literals.

type MailboxAttr

type MailboxAttr string

MailboxAttr is a mailbox attribute.

Mailbox attributes are defined in RFC 9051 section 7.3.1.

const (
	// Base attributes
	MailboxAttrNonExistent   MailboxAttr = "\\NonExistent"
	MailboxAttrNoInferiors   MailboxAttr = "\\Noinferiors"
	MailboxAttrNoSelect      MailboxAttr = "\\Noselect"
	MailboxAttrHasChildren   MailboxAttr = "\\HasChildren"
	MailboxAttrHasNoChildren MailboxAttr = "\\HasNoChildren"
	MailboxAttrMarked        MailboxAttr = "\\Marked"
	MailboxAttrUnmarked      MailboxAttr = "\\Unmarked"
	MailboxAttrSubscribed    MailboxAttr = "\\Subscribed"
	MailboxAttrRemote        MailboxAttr = "\\Remote"

	// Role (aka. "special-use") attributes
	MailboxAttrAll       MailboxAttr = "\\All"
	MailboxAttrArchive   MailboxAttr = "\\Archive"
	MailboxAttrDrafts    MailboxAttr = "\\Drafts"
	MailboxAttrFlagged   MailboxAttr = "\\Flagged"
	MailboxAttrJunk      MailboxAttr = "\\Junk"
	MailboxAttrSent      MailboxAttr = "\\Sent"
	MailboxAttrTrash     MailboxAttr = "\\Trash"
	MailboxAttrImportant MailboxAttr = "\\Important" // RFC 8457
)

type NamespaceData

type NamespaceData struct {
	Personal []NamespaceDescriptor
	Other    []NamespaceDescriptor
	Shared   []NamespaceDescriptor
}

NamespaceData is the data returned by the NAMESPACE command.

type NamespaceDescriptor

type NamespaceDescriptor struct {
	Prefix string
	Delim  rune
}

NamespaceDescriptor describes a namespace.

type NumSet

type NumSet interface {
	// String returns the IMAP representation of the message number set.
	String() string
	// Dynamic returns true if the set contains "*" or "n:*" ranges or if the
	// set represents the special SEARCHRES marker.
	Dynamic() bool
	// contains filtered or unexported methods
}

NumSet is a set of numbers identifying messages. NumSet is either a SeqSet or a UIDSet.

type PartSpecifier

type PartSpecifier string

PartSpecifier describes whether to fetch a part's header, body, or both.

const (
	PartSpecifierNone   PartSpecifier = ""
	PartSpecifierHeader PartSpecifier = "HEADER"
	PartSpecifierMIME   PartSpecifier = "MIME"
	PartSpecifierText   PartSpecifier = "TEXT"
)

type QuotaResourceType

type QuotaResourceType string

QuotaResourceType is a QUOTA resource type.

See RFC 9208 section 5.

const (
	QuotaResourceStorage           QuotaResourceType = "STORAGE"
	QuotaResourceMessage           QuotaResourceType = "MESSAGE"
	QuotaResourceMailbox           QuotaResourceType = "MAILBOX"
	QuotaResourceAnnotationStorage QuotaResourceType = "ANNOTATION-STORAGE"
)

type ResponseCode

type ResponseCode string

ResponseCode is a response code.

const (
	ResponseCodeAlert                ResponseCode = "ALERT"
	ResponseCodeAlreadyExists        ResponseCode = "ALREADYEXISTS"
	ResponseCodeAuthenticationFailed ResponseCode = "AUTHENTICATIONFAILED"
	ResponseCodeAuthorizationFailed  ResponseCode = "AUTHORIZATIONFAILED"
	ResponseCodeBadCharset           ResponseCode = "BADCHARSET"
	ResponseCodeCannot               ResponseCode = "CANNOT"
	ResponseCodeClientBug            ResponseCode = "CLIENTBUG"
	ResponseCodeContactAdmin         ResponseCode = "CONTACTADMIN"
	ResponseCodeCorruption           ResponseCode = "CORRUPTION"
	ResponseCodeExpired              ResponseCode = "EXPIRED"
	ResponseCodeHasChildren          ResponseCode = "HASCHILDREN"
	ResponseCodeInUse                ResponseCode = "INUSE"
	ResponseCodeLimit                ResponseCode = "LIMIT"
	ResponseCodeNonExistent          ResponseCode = "NONEXISTENT"
	ResponseCodeNoPerm               ResponseCode = "NOPERM"
	ResponseCodeOverQuota            ResponseCode = "OVERQUOTA"
	ResponseCodeParse                ResponseCode = "PARSE"
	ResponseCodePrivacyRequired      ResponseCode = "PRIVACYREQUIRED"
	ResponseCodeServerBug            ResponseCode = "SERVERBUG"
	ResponseCodeTryCreate            ResponseCode = "TRYCREATE"
	ResponseCodeUnavailable          ResponseCode = "UNAVAILABLE"
	ResponseCodeUnknownCTE           ResponseCode = "UNKNOWN-CTE"

	// METADATA
	ResponseCodeTooMany   ResponseCode = "TOOMANY"
	ResponseCodeNoPrivate ResponseCode = "NOPRIVATE"

	// APPENDLIMIT
	ResponseCodeTooBig ResponseCode = "TOOBIG"
)

type SearchCriteria

type SearchCriteria struct {
	SeqNum []SeqSet
	UID    []UIDSet

	// Only the date is used, the time and timezone are ignored
	Since      time.Time
	Before     time.Time
	SentSince  time.Time
	SentBefore time.Time

	Header []SearchCriteriaHeaderField
	Body   []string
	Text   []string

	Flag    []Flag
	NotFlag []Flag

	Larger  int64
	Smaller int64

	Not []SearchCriteria
	Or  [][2]SearchCriteria

	ModSeq *SearchCriteriaModSeq // requires CONDSTORE
}

SearchCriteria is a criteria for the SEARCH command.

When multiple fields are populated, the result is the intersection ("and" function) of all messages that match the fields.

And, Not and Or can be used to combine multiple criteria together. For instance, the following criteria matches messages not containing "hello":

SearchCriteria{Not: []SearchCriteria{{
	Body: []string{"hello"},
}}}

The following criteria matches messages containing either "hello" or "world":

SearchCriteria{Or: [][2]SearchCriteria{{
	{Body: []string{"hello"}},
	{Body: []string{"world"}},
}}}

func (*SearchCriteria) And

func (criteria *SearchCriteria) And(other *SearchCriteria)

And intersects two search criteria.

type SearchCriteriaHeaderField

type SearchCriteriaHeaderField struct {
	Key, Value string
}

type SearchCriteriaMetadataType

type SearchCriteriaMetadataType string
const (
	SearchCriteriaMetadataAll     SearchCriteriaMetadataType = "all"
	SearchCriteriaMetadataPrivate SearchCriteriaMetadataType = "priv"
	SearchCriteriaMetadataShared  SearchCriteriaMetadataType = "shared"
)

type SearchCriteriaModSeq

type SearchCriteriaModSeq struct {
	ModSeq       uint64
	MetadataName string
	MetadataType SearchCriteriaMetadataType
}

type SearchData

type SearchData struct {
	All NumSet

	// requires IMAP4rev2 or ESEARCH
	UID   bool
	Min   uint32
	Max   uint32
	Count uint32

	// requires CONDSTORE
	ModSeq uint64
}

SearchData is the data returned by a SEARCH command.

func (*SearchData) AllSeqNums

func (data *SearchData) AllSeqNums() []uint32

AllSeqNums returns All as a slice of sequence numbers.

func (*SearchData) AllUIDs

func (data *SearchData) AllUIDs() []UID

AllUIDs returns All as a slice of UIDs.

type SearchOptions

type SearchOptions struct {
	// Requires IMAP4rev2 or ESEARCH
	ReturnMin   bool
	ReturnMax   bool
	ReturnAll   bool
	ReturnCount bool
	// Requires IMAP4rev2 or SEARCHRES
	ReturnSave bool
}

SearchOptions contains options for the SEARCH command.

type SectionPartial

type SectionPartial struct {
	Offset, Size int64
}

SectionPartial describes a byte range when fetching a message's payload.

type SelectData

type SelectData struct {
	// Flags defined for this mailbox
	Flags []Flag
	// Flags that the client can change permanently
	PermanentFlags []Flag
	// Number of messages in this mailbox (aka. "EXISTS")
	NumMessages uint32
	UIDNext     UID
	UIDValidity uint32

	List *ListData // requires IMAP4rev2

	HighestModSeq uint64 // requires CONDSTORE
}

SelectData is the data returned by a SELECT command.

In the old RFC 2060, PermanentFlags, UIDNext and UIDValidity are optional.

type SelectOptions

type SelectOptions struct {
	ReadOnly  bool
	CondStore bool // requires CONDSTORE
}

SelectOptions contains options for the SELECT or EXAMINE command.

type SeqRange

type SeqRange struct {
	Start, Stop uint32
}

SeqRange is a range of message sequence numbers.

type SeqSet

type SeqSet []SeqRange

SeqSet is a set of message sequence numbers.

func SeqSetNum

func SeqSetNum(nums ...uint32) SeqSet

SeqSetNum returns a new SeqSet containing the specified sequence numbers.

func (*SeqSet) AddNum

func (s *SeqSet) AddNum(nums ...uint32)

AddNum inserts new sequence numbers into the set. The value 0 represents "*".

func (*SeqSet) AddRange

func (s *SeqSet) AddRange(start, stop uint32)

AddRange inserts a new range into the set.

func (*SeqSet) AddSet

func (s *SeqSet) AddSet(other SeqSet)

AddSet inserts all sequence numbers from other into s.

func (*SeqSet) Contains

func (s *SeqSet) Contains(num uint32) bool

Contains returns true if the non-zero sequence number num is contained in the set.

func (SeqSet) Dynamic

func (s SeqSet) Dynamic() bool

func (*SeqSet) Nums

func (s *SeqSet) Nums() ([]uint32, bool)

Nums returns a slice of all sequence numbers contained in the set.

func (SeqSet) String

func (s SeqSet) String() string

type StatusData

type StatusData struct {
	Mailbox string

	NumMessages *uint32
	UIDNext     UID
	UIDValidity uint32
	NumUnseen   *uint32
	NumDeleted  *uint32
	Size        *int64

	AppendLimit    *uint32
	DeletedStorage *int64
	HighestModSeq  uint64
}

StatusData is the data returned by a STATUS command.

The mailbox name is always populated. The remaining fields are optional.

type StatusOptions

type StatusOptions struct {
	NumMessages bool
	UIDNext     bool
	UIDValidity bool
	NumUnseen   bool
	NumDeleted  bool // requires IMAP4rev2 or QUOTA
	Size        bool // requires IMAP4rev2 or STATUS=SIZE

	AppendLimit    bool // requires APPENDLIMIT
	DeletedStorage bool // requires QUOTA=RES-STORAGE
	HighestModSeq  bool // requires CONDSTORE
}

StatusOptions contains options for the STATUS command.

type StatusResponse

type StatusResponse struct {
	Type StatusResponseType
	Code ResponseCode
	Text string
}

StatusResponse is a generic status response.

See RFC 9051 section 7.1.

type StatusResponseType

type StatusResponseType string

StatusResponseType is a generic status response type.

const (
	StatusResponseTypeOK      StatusResponseType = "OK"
	StatusResponseTypeNo      StatusResponseType = "NO"
	StatusResponseTypeBad     StatusResponseType = "BAD"
	StatusResponseTypePreAuth StatusResponseType = "PREAUTH"
	StatusResponseTypeBye     StatusResponseType = "BYE"
)

type StoreFlags

type StoreFlags struct {
	Op     StoreFlagsOp
	Silent bool
	Flags  []Flag
}

StoreFlags alters message flags.

type StoreFlagsOp

type StoreFlagsOp int

StoreFlagsOp is a flag operation: set, add or delete.

const (
	StoreFlagsSet StoreFlagsOp = iota
	StoreFlagsAdd
	StoreFlagsDel
)

type StoreOptions

type StoreOptions struct {
	UnchangedSince uint64 // requires CONDSTORE
}

StoreOptions contains options for the STORE command.

type ThreadAlgorithm

type ThreadAlgorithm string

ThreadAlgorithm is a threading algorithm.

const (
	ThreadOrderedSubject ThreadAlgorithm = "ORDEREDSUBJECT"
	ThreadReferences     ThreadAlgorithm = "REFERENCES"
)

type UID

type UID uint32

UID is a message unique identifier.

type UIDRange

type UIDRange struct {
	Start, Stop UID
}

UIDRange is a range of message UIDs.

type UIDSet

type UIDSet []UIDRange

UIDSet is a set of message UIDs.

func SearchRes

func SearchRes() UIDSet

SearchRes returns a special marker which can be used instead of a UIDSet to reference the last SEARCH result. On the wire, it's encoded as '$'.

It requires IMAP4rev2 or the SEARCHRES extension.

func UIDSetNum

func UIDSetNum(uids ...UID) UIDSet

UIDSetNum returns a new UIDSet containing the specified UIDs.

func (*UIDSet) AddNum

func (s *UIDSet) AddNum(uids ...UID)

AddNum inserts new UIDs into the set. The value 0 represents "*".

func (*UIDSet) AddRange

func (s *UIDSet) AddRange(start, stop UID)

AddRange inserts a new range into the set.

func (*UIDSet) AddSet

func (s *UIDSet) AddSet(other UIDSet)

AddSet inserts all UIDs from other into s.

func (UIDSet) Contains

func (s UIDSet) Contains(uid UID) bool

Contains returns true if the non-zero UID uid is contained in the set.

func (UIDSet) Dynamic

func (s UIDSet) Dynamic() bool

func (UIDSet) Nums

func (s UIDSet) Nums() ([]UID, bool)

Nums returns a slice of all UIDs contained in the set.

func (UIDSet) String

func (s UIDSet) String() string

Directories

Path Synopsis
cmd
Package imapclient implements an IMAP client.
Package imapclient implements an IMAP client.
Package imapserver implements an IMAP server.
Package imapserver implements an IMAP server.
imapmemserver
Package imapmemserver implements an in-memory IMAP server.
Package imapmemserver implements an in-memory IMAP server.
imapwire
Package imapwire implements the IMAP wire protocol.
Package imapwire implements the IMAP wire protocol.
utf7
Package utf7 implements modified UTF-7 encoding defined in RFC 3501 section 5.1.3
Package utf7 implements modified UTF-7 encoding defined in RFC 3501 section 5.1.3

Jump to

Keyboard shortcuts

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