email

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllTools

func AllTools(s Service) []tool.Tool

func NewReadEmailTool

func NewReadEmailTool(s Service) tool.CallableTool

func NewSendEmailTool

func NewSendEmailTool(s Service) tool.CallableTool

Types

type Config

type Config struct {
	Provider string `json:"provider,omitempty" yaml:"Provider,omitempty" toml:"Provider,omitempty"` // smtp, gmail_api, sendgrid
	Host     string `json:"host" yaml:"Host,omitempty" toml:"Host,omitempty"`                       // SMTP Host
	Port     int    `json:"port" yaml:"Port,omitempty" toml:"Port,omitempty,omitzero"`              // SMTP Port
	Username string `json:"username" yaml:"Username,omitempty" toml:"Username,omitempty"`
	Password string `json:"password" yaml:"Password,omitempty" toml:"Password,omitempty"`

	// IMAP settings for reading emails
	IMAPHost string `json:"imap_host,omitempty" yaml:"IMAPHost,omitempty" toml:"IMAPHost,omitempty"`
	IMAPPort int    `json:"imap_port,omitempty" yaml:"IMAPPort,omitempty" toml:"IMAPPort,omitempty,omitzero"`

	// IMAPTLSConfig is set by the application from security.CryptoConfig.TLSConfig()
	// to enforce NIST 2030 minimums (TLS 1.2+). Not loaded from config file.
	IMAPTLSConfig *tls.Config `json:"-" yaml:"-" toml:"-"`
}

Config holds configuration for Email providers

func (Config) New

func (cfg Config) New() (Service, error)

New creates a new Email Service based on the configuration

type Email

type Email struct {
	From        string
	Subject     string
	Body        string // Plain text body
	Date        string
	Attachments []string // Summaries of attachments
}

type ReadEmailRequest

type ReadEmailRequest struct {
	Filter string `json:"filter" jsonschema:"description=Filter instructions (e.g. 'unread', 'security alert')"`
}

type SendEmailRequest

type SendEmailRequest struct {
	To      []string `json:"to" jsonschema:"description=Recipient email addresses,required"`
	Subject string   `json:"subject" jsonschema:"description=Email subject,required"`
	Body    string   `json:"body" jsonschema:"description=Email body content,required"`
}

type SendRequest

type SendRequest struct {
	To      []string
	Subject string
	Body    string
	IsHTML  bool
}

type Service

type Service interface {
	Send(ctx context.Context, req SendRequest) error
	Read(ctx context.Context, filter string) ([]*Email, error)
	// Validate performs a lightweight health check to detect misconfigurations at startup.
	Validate(ctx context.Context) error
}

Service provides capabilities to send and read emails.

type ToolProvider

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

ToolProvider wraps an email Service and satisfies the tools.ToolProviders interface so email tools can be passed directly to tools.NewRegistry. Without this, email tool construction would be inlined in the registry.

func NewToolProvider

func NewToolProvider(svc Service) *ToolProvider

NewToolProvider creates a ToolProvider from an already-initialised email service.

func (*ToolProvider) GetTools

func (p *ToolProvider) GetTools() []tool.Tool

GetTools returns all email tools (send + read) wired to the underlying service.

Jump to

Keyboard shortcuts

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