gmail

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package gmail provides a Gmail email provider for omnichat using the Gmail API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// CredentialsJSON is the Google OAuth credentials JSON (client_secret.json contents).
	// This is the application credentials, not the user token.
	CredentialsJSON []byte

	// TokenFile is the path to store/load the OAuth token.
	// If empty, defaults to ~/.agentcomms/gmail_token.json
	TokenFile string

	// FromAddress is the email address to send from.
	// Use "me" to send from the authenticated user's address.
	FromAddress string

	// Scopes defines the OAuth scopes to request.
	// If empty, defaults to gmail.GmailSendScope.
	Scopes []string

	// Logger is the logger instance.
	Logger *slog.Logger

	// ForceNewToken forces re-authentication even if a token exists.
	ForceNewToken bool
}

Config configures the Gmail provider.

type IncomingEmail

type IncomingEmail struct {
	ID        string
	From      string
	To        string
	Subject   string
	Body      string
	BodyHTML  string
	Timestamp time.Time
	ThreadID  string
	Labels    []string
}

IncomingEmail represents an email received (for future Watch API support).

type Provider

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

Provider implements the Provider interface for Gmail.

func New

func New(config Config) (*Provider, error)

New creates a new Gmail provider.

func (*Provider) Connect

func (p *Provider) Connect(ctx context.Context) error

Connect establishes connection to Gmail API via OAuth.

func (*Provider) Disconnect

func (p *Provider) Disconnect(ctx context.Context) error

Disconnect closes the Gmail connection.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

func (*Provider) OnEvent

func (p *Provider) OnEvent(handler provider.EventHandler)

OnEvent registers an event handler.

func (*Provider) OnMessage

func (p *Provider) OnMessage(handler provider.MessageHandler)

OnMessage registers a message handler. Note: Gmail inbound requires Watch API setup which is not yet implemented.

func (*Provider) Send

func (p *Provider) Send(ctx context.Context, chatID string, msg provider.OutgoingMessage) error

Send sends an email to a recipient. The chatID is the recipient's email address.

func (*Provider) SendEmail

func (p *Provider) SendEmail(ctx context.Context, to, subject, body string, html bool) error

SendEmail is a convenience method for sending emails with explicit parameters.

Jump to

Keyboard shortcuts

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