Versions in this module Expand all Collapse all v1 v1.0.1 Aug 6, 2026 v1.0.0 Aug 5, 2026 Changes in this version + var ErrAccountExists = errors.New("mailkit: account already exists") + var ErrAccountNotFound = errors.New("mailkit: account not found") + var ErrClosed = errors.New("mailkit: closed") + var ErrCursorConflict = errors.New("mailkit: cursor conflict") + var ErrInvalidConfig = errors.New("mailkit: invalid config") + var ErrMessageTooLarge = errors.New("mailkit: message too large") + func IsTemporary(err error) bool + type AccountConfig struct + AllowInsecureAuth bool + Auth Auth + BatchSize int + CommandTimeout time.Duration + ConnectTimeout time.Duration + DialContext DialContextFunc + Endpoint Endpoint + ID string + IdleRefresh time.Duration + Mailbox string + PollInterval time.Duration + PreferIMAPIdle bool + Query SearchQuery + Reconnect ReconnectPolicy + ReplayHistory bool + RetryDelay time.Duration + TLSConfig *tls.Config + func NewAccountConfig(id string, provider ProviderProfile, auth Auth) AccountConfig + func (c AccountConfig) Validate() error + type AccountState string + const AccountStateConnecting + const AccountStateFault + const AccountStateOffline + const AccountStateOnline + const AccountStateReconnecting + const AccountStateStopping + type AccountStatus struct + AccountID string + Committed uint64 + Cursor Cursor + DesiredOnline bool + Generation uint64 + LastConnectedAt time.Time + LastError string + LastMessageAt time.Time + LastStateAt time.Time + Reconnects uint64 + Retried uint64 + Skipped uint64 + State AccountState + type Address struct + Email string + Name string + func (a Address) String() string + func (a Address) Validate() error + type Attachment struct + ContentID string + ContentType string + Filename string + Inline bool + Source AttachmentSource + func BytesAttachment(filename string, data []byte) Attachment + func FileAttachment(path string) Attachment + type AttachmentSource func() (io.ReadCloser, error) + type Auth struct + func OAuth2Auth(username string, source TokenSource) Auth + func PasswordAuth(username, password string) Auth + func (a Auth) GoString() string + func (a Auth) Mode() AuthMode + func (a Auth) String() string + func (a Auth) Username() string + type AuthMode string + const AuthModePassword + const AuthModeXOAUTH2 + type BatchResult struct + Failed int + Results []SendResult + Succeeded int + type Cursor struct + Key CursorKey + LastUID uint32 + UIDValidity uint32 + UpdatedAt time.Time + type CursorKey struct + AccountID string + Mailbox string + type CursorStore interface + Delete func(ctx context.Context, key CursorKey) error + Load func(ctx context.Context, key CursorKey) (Cursor, bool, error) + Save func(ctx context.Context, cursor Cursor) error + type DialContextFunc func(ctx context.Context, network, address string) (net.Conn, error) + type Endpoint struct + Host string + Port int + TLSMode TLSMode + func (e Endpoint) Validate() error + type Error struct + Err error + Kind ErrorKind + Op string + Temporary bool + func (e *Error) Error() string + func (e *Error) Unwrap() error + type ErrorKind string + const ErrorKindAuthentication + const ErrorKindConfig + const ErrorKindConnection + const ErrorKindLifecycle + const ErrorKindMessage + const ErrorKindProtocol + type Event struct + AccountID string + Err error + MessageID string + OccurredAt time.Time + State AccountState + Type EventType + UID uint32 + type EventType string + const EventAccountError + const EventMessageCommitted + const EventMessageRetried + const EventMessageSkipped + const EventStateChanged + type FetchOptions struct + IncludeAttachments bool + IncludeBody bool + MaxAttachmentBytes int64 + MaxMessageBytes int64 + type Hub struct + func NewHub(config HubConfig) (*Hub, error) + func (h *Hub) Close(ctx context.Context) error + func (h *Hub) DroppedEvents() uint64 + func (h *Hub) Events() <-chan Event + func (h *Hub) List() []AccountStatus + func (h *Hub) Offline(ctx context.Context, accountID string) error + func (h *Hub) Online(ctx context.Context, accountID string) error + func (h *Hub) Register(config AccountConfig) error + func (h *Hub) Remove(ctx context.Context, accountID string) error + func (h *Hub) Status(accountID string) (AccountStatus, bool) + func (h *Hub) Update(ctx context.Context, config AccountConfig) error + type HubConfig struct + CursorStore CursorStore + EventBuffer int + Handler MessageHandler + type Mailbox interface + Close func(ctx context.Context) error + Search func(ctx context.Context, query SearchQuery) (SearchResult, error) + func OpenMailbox(ctx context.Context, config MailboxConfig) (Mailbox, error) + type MailboxConfig struct + AccountID string + AllowInsecureAuth bool + Auth Auth + CommandTimeout time.Duration + ConnectTimeout time.Duration + DialContext DialContextFunc + Endpoint Endpoint + Mailbox string + TLSConfig *tls.Config + func (c MailboxConfig) Validate() error + type MemoryCursorStore struct + func NewMemoryCursorStore() *MemoryCursorStore + func (s *MemoryCursorStore) Delete(ctx context.Context, key CursorKey) error + func (s *MemoryCursorStore) Load(ctx context.Context, key CursorKey) (Cursor, bool, error) + func (s *MemoryCursorStore) Save(ctx context.Context, cursor Cursor) error + type MessageHandler interface + Handle func(ctx context.Context, message ReceivedMessage) ProcessResult + type MessageHandlerFunc func(ctx context.Context, message ReceivedMessage) ProcessResult + func (f MessageHandlerFunc) Handle(ctx context.Context, message ReceivedMessage) ProcessResult + type OutgoingMessage struct + Attachments []Attachment + BCC []Address + CC []Address + From Address + HTML string + Headers map[string][]string + MessageID string + ReplyTo []Address + Subject string + Text string + To []Address + func (m OutgoingMessage) Validate() error + type ProcessAction string + const ProcessCommit + const ProcessRetry + const ProcessSkip + type ProcessResult struct + Action ProcessAction + Err error + func CommitMessage() ProcessResult + func RetryMessage(err error) ProcessResult + func SkipMessage(err error) ProcessResult + type ProviderName string + const ProviderGmail + const ProviderMicrosoft + const ProviderNetEase126 + const ProviderNetEase163 + const ProviderQQ + const ProviderTencentExmail + type ProviderProfile struct + AuthModes []AuthMode + IMAP Endpoint + Name string + PreferIMAPIdle bool + SMTP Endpoint + func BuiltinProvider(name ProviderName) (ProviderProfile, error) + func (p ProviderProfile) SupportsAuth(mode AuthMode) bool + func (p ProviderProfile) Validate() error + type ReceivedAttachment struct + ContentID string + ContentType string + Data []byte + Filename string + Inline bool + Size int64 + type ReceivedMessage struct + AccountID string + Attachments []ReceivedAttachment + CC []Address + Date time.Time + Flags []string + From []Address + HTML string + Headers map[string][]string + InReplyTo string + Mailbox string + MessageID string + ParseError error + ReceivedAt time.Time + ReplyTo []Address + Size uint32 + Subject string + Text string + To []Address + UID uint32 + UIDValidity uint32 + type ReconnectPolicy struct + InitialDelay time.Duration + JitterFraction float64 + MaxDelay time.Duration + Multiplier float64 + func (p ReconnectPolicy) Validate() error + type RetryPolicy struct + Backoff time.Duration + MaxAttempts int + type SearchQuery struct + AfterUID uint32 + Before time.Time + Fetch FetchOptions + From string + Headers map[string]string + Limit int + Mailbox string + Since time.Time + Subject string + Text string + To string + WithFlags []string + WithoutFlags []string + func (q SearchQuery) Validate() error + type SearchResult struct + Mailbox string + Messages []ReceivedMessage + UIDValidity uint32 + type SendResult struct + Attempts int + Err error + Index int + MessageID string + type Sender interface + Close func(ctx context.Context) error + Send func(ctx context.Context, message OutgoingMessage) error + SendBatch func(ctx context.Context, messages []OutgoingMessage) BatchResult + Stats func() SenderStats + func NewSender(config SenderConfig) (Sender, error) + type SenderConfig struct + AllowInsecureAuth bool + Auth Auth + ConnectionMaxLifetime time.Duration + DialContext DialContextFunc + Endpoint Endpoint + MaxConnections int + Retry RetryPolicy + TLSConfig *tls.Config + Timeout time.Duration + func (c SenderConfig) Validate() error + type SenderStats struct + Closed bool + Failed uint64 + InFlight int64 + MaxConnections int + Retried uint64 + Sent uint64 + type TLSMode string + const TLSModeImplicit + const TLSModePlain + const TLSModeSTARTTLS + type TokenSource interface + Token func(ctx context.Context) (string, error) + type TokenSourceFunc func(ctx context.Context) (string, error) + func (f TokenSourceFunc) Token(ctx context.Context) (string, error)