email

package
v0.99.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package email implements the email capability adapter.

Index

Constants

View Source
const (
	OpSend       = "send"
	OpList       = "list"
	OpGet        = "get"
	OpSearch     = "search"
	OpMarkRead   = "mark_read"
	OpMarkUnread = "mark_unread"
	OpHealth     = "health"
)

Operation name constants for the email capability.

Variables

This section is empty.

Functions

func CatalogSpec

func CatalogSpec() capability.Spec

CatalogSpec returns capability metadata for documentation.

func NewPoller

func NewPoller() capability.PollingResource

NewPoller creates a MessagePoller. Returns nil when the provider is not configured.

func Register

func Register(app string, svc Service) error

Register registers the email capability with hub and invoker registry. When svc is nil the provider is not configured and registration is skipped.

Types

type Adapter

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

Adapter implements Service using the email provider client.

func (*Adapter) Get

func (a *Adapter) Get(ctx context.Context, id string) (*MailMessage, error)

func (*Adapter) HealthCheck

func (a *Adapter) HealthCheck(ctx context.Context) (bool, error)

func (*Adapter) List

func (*Adapter) ListRawEvents

func (a *Adapter) ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)

func (*Adapter) MarkEmittedSeen

func (a *Adapter) MarkEmittedSeen(ctx context.Context, ids []string) error

func (*Adapter) MarkRead

func (a *Adapter) MarkRead(ctx context.Context, id string) error

func (*Adapter) MarkUnread

func (a *Adapter) MarkUnread(ctx context.Context, id string) error

func (*Adapter) Search

func (*Adapter) Send

func (a *Adapter) Send(ctx context.Context, in SendInput) error

type ListInput

type ListInput struct {
	Mailbox    string
	UnseenOnly *bool
	Page       capability.PageRequest
}

ListInput holds parameters for listing messages.

type MailAttachment

type MailAttachment = capability.MailAttachment

MailAttachment describes an attachment without binary payload.

type MailMessage

type MailMessage = capability.MailMessage

MailMessage is the capability-facing email message type.

type MessagePoller

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

MessagePoller polls IMAP for new/updated messages.

func NewPollerWithService

func NewPollerWithService(svc Service) *MessagePoller

NewPollerWithService creates a MessagePoller with a specific service.

func (*MessagePoller) AfterEmit

func (p *MessagePoller) AfterEmit(ctx context.Context, items []any) error

AfterEmit marks emitted messages as seen when mark_seen_after_emit is enabled.

func (*MessagePoller) Capability

func (*MessagePoller) Capability() string

func (*MessagePoller) ContentHash

func (*MessagePoller) ContentHash(item any) string

func (*MessagePoller) CursorField

func (*MessagePoller) CursorField() string

func (*MessagePoller) DefaultInterval

func (*MessagePoller) DefaultInterval() time.Duration

func (*MessagePoller) DiffKey

func (*MessagePoller) DiffKey(item any) string

func (*MessagePoller) List

func (p *MessagePoller) List(ctx context.Context, cursor string) (capability.PollResult, error)

func (*MessagePoller) ResourceName

func (*MessagePoller) ResourceName() string

type SearchInput

type SearchInput struct {
	Mailbox string
	From    string
	To      string
	Subject string
	Since   *time.Time
	Before  *time.Time
	Unseen  *bool
	Page    capability.PageRequest
}

SearchInput holds parameters for searching messages.

type SendInput

type SendInput struct {
	To       []string
	Cc       []string
	Bcc      []string
	Subject  string
	Text     string
	HTML     string
	FromName string
}

SendInput holds parameters for sending an email.

type Service

type Service interface {
	Send(ctx context.Context, in SendInput) error
	List(ctx context.Context, in ListInput) (*capability.ListResult[MailMessage], error)
	Get(ctx context.Context, id string) (*MailMessage, error)
	Search(ctx context.Context, in SearchInput) (*capability.ListResult[MailMessage], error)
	MarkRead(ctx context.Context, id string) error
	MarkUnread(ctx context.Context, id string) error
	HealthCheck(ctx context.Context) (bool, error)
	ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
	MarkEmittedSeen(ctx context.Context, ids []string) error
}

Service defines the email capability contract.

func New

func New() Service

New creates an Adapter from YAML config. Returns nil when not configured.

func NewWithClient

func NewWithClient(c client) Service

NewWithClient creates an Adapter with a specific client (tests).

Jump to

Keyboard shortcuts

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