Documentation
¶
Overview ¶
Package backend defines the Provider interface for multi-protocol email support.
Index ¶
- Variables
- func RegisterBackend(protocol string, fn NewFunc)
- type Attachment
- type Capabilities
- type CapabilityProvider
- type Email
- type EmailReader
- type EmailSearcher
- type EmailSender
- type EmailWriter
- type Folder
- type FolderManager
- type NewFunc
- type Notifier
- type NotifyEvent
- type NotifyType
- type OutgoingEmail
- type Provider
- type SearchQuery
Constants ¶
This section is empty.
Variables ¶
var ErrNotSupported = errors.New("operation not supported by this provider")
ErrNotSupported is returned when a provider does not support an operation.
Functions ¶
func RegisterBackend ¶
RegisterBackend registers a backend constructor for a protocol name.
Types ¶
type Attachment ¶
type Attachment struct {
Filename string
PartID string
Data []byte
Encoding string
MIMEType string
ContentID string
Inline bool
IsSMIMESignature bool
SMIMEVerified bool
IsSMIMEEncrypted bool
IsPGPSignature bool
PGPVerified bool
IsPGPEncrypted bool
}
Attachment holds data for an email attachment.
type Capabilities ¶
type Capabilities struct {
CanSend bool
CanMove bool
CanArchive bool
CanPush bool
CanSearchServer bool
CanFetchFolders bool
SupportsSMIME bool
}
Capabilities describes what a backend supports.
type CapabilityProvider ¶
type CapabilityProvider interface {
Capabilities() Capabilities
}
CapabilityProvider optionally reports what a backend can do.
type Email ¶
type Email struct {
UID uint32
From string
To []string
ReplyTo []string
Subject string
Body string
Date time.Time
IsRead bool
MessageID string
InReplyTo string
References []string
Attachments []Attachment
AccountID string
}
Email represents a single email message.
type EmailReader ¶
type EmailReader interface {
FetchEmails(ctx context.Context, folder string, limit, offset uint32) ([]Email, error)
// FetchEmailBody returns the chosen body, its MIME type ("text/html" or
// "text/plain"; empty when unknown), parsed attachments, and any error.
FetchEmailBody(ctx context.Context, folder string, uid uint32) (string, string, []Attachment, error)
FetchAttachment(ctx context.Context, folder string, uid uint32, partID, encoding string) ([]byte, error)
}
EmailReader fetches emails and their content.
type EmailSearcher ¶ added in v0.36.0
type EmailSearcher interface {
Search(ctx context.Context, folder string, query SearchQuery) ([]Email, error)
}
EmailSearcher searches emails server-side.
type EmailSender ¶
type EmailSender interface {
SendEmail(ctx context.Context, msg *OutgoingEmail) error
}
EmailSender sends outgoing email.
type EmailWriter ¶
type EmailWriter interface {
MarkAsRead(ctx context.Context, folder string, uid uint32) error
MarkAsUnread(ctx context.Context, folder string, uid uint32) error
DeleteEmail(ctx context.Context, folder string, uid uint32) error
ArchiveEmail(ctx context.Context, folder string, uid uint32) error
MoveEmail(ctx context.Context, uid uint32, srcFolder, dstFolder string) error
// Batch operations
DeleteEmails(ctx context.Context, folder string, uids []uint32) error
ArchiveEmails(ctx context.Context, folder string, uids []uint32) error
MoveEmails(ctx context.Context, uids []uint32, srcFolder, dstFolder string) error
}
EmailWriter modifies email state.
type FolderManager ¶
FolderManager lists folders/mailboxes.
type Notifier ¶
type Notifier interface {
Watch(ctx context.Context, folder string) (<-chan NotifyEvent, func(), error)
}
Notifier provides real-time notifications for new email.
type NotifyEvent ¶
type NotifyEvent struct {
Type NotifyType
Folder string
AccountID string
}
NotifyEvent is emitted by Watch() when something changes in a mailbox.
type NotifyType ¶
type NotifyType int
NotifyType indicates the kind of notification event.
const ( NotifyNewEmail NotifyType = iota NotifyExpunge NotifyFlagChange )
type OutgoingEmail ¶
type OutgoingEmail struct {
To []string
Cc []string
Bcc []string
Subject string
PlainBody string
HTMLBody string
Images map[string][]byte
Attachments map[string][]byte
InReplyTo string
References []string
SignSMIME bool
EncryptSMIME bool
SignPGP bool
EncryptPGP bool
}
OutgoingEmail contains everything needed to send an email.
type Provider ¶
type Provider interface {
EmailReader
EmailWriter
EmailSender
EmailSearcher
FolderManager
Notifier
Close() error
}
Provider is the unified interface that all email backends must implement.
type SearchQuery ¶ added in v0.36.0
type SearchQuery struct {
Raw string
From string
To string
Subject string
Body string
Since time.Time
Before time.Time
LargerThan int
Limit uint32
}
SearchQuery is the parsed form of a user query string.
func ParseSearchQuery ¶ added in v0.36.0
func ParseSearchQuery(s string) SearchQuery
ParseSearchQuery parses a compact search DSL into a SearchQuery.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package imap implements the backend.Provider interface by delegating to the existing fetcher and sender packages.
|
Package imap implements the backend.Provider interface by delegating to the existing fetcher and sender packages. |
|
Package jmap implements the backend.Provider interface using the JMAP protocol (RFC 8620 Core + RFC 8621 Mail).
|
Package jmap implements the backend.Provider interface using the JMAP protocol (RFC 8620 Core + RFC 8621 Mail). |
|
Package maildir implements the backend.Provider interface for local Maildir mailboxes (the `mutt -f Maildir` style).
|
Package maildir implements the backend.Provider interface for local Maildir mailboxes (the `mutt -f Maildir` style). |
|
Package pop3 implements the backend.Provider interface using POP3 for reading email and SMTP for sending.
|
Package pop3 implements the backend.Provider interface using POP3 for reading email and SMTP for sending. |