ses

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New captures options and returns a DI-injectable constructor.

func NewWithCustomProvider

func NewWithCustomProvider[T gas.TemplateProvider](opts ...Option) func(T, gas.ConfigProvider, gas.Logger) *Service

NewWithCustomProvider creates a new Service instance with a custom TemplateProvider and optional configurations.

Types

type Config

type Config struct {
	env.WithGasEnv

	Email Settings
}

Config holds SES email settings.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with zero-value defaults.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the Config for correctness.

type Option

type Option func(*Service)

Option configures a Service.

func WithClient

func WithClient(client sesClient) Option

WithClient injects a pre-configured SES client. Useful for testing or when the caller manages AWS credentials externally.

func WithConfig

func WithConfig(cfg *Config) Option

WithConfig sets a custom configuration.

type Service

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

Service is an SES-backed email sender implementing gas.Service and gas.EmailProvider.

func (*Service) CheckReady

func (s *Service) CheckReady(_ context.Context) error

CheckReady reports whether the service can accept Send calls. Returns email.ErrClosed once Close has been invoked so probes depool the pod during shutdown/drain.

func (*Service) Client

func (s *Service) Client() *awsses.Client

Client returns the underlying *ses.Client for advanced operations beyond the EmailProvider interface. Returns nil if a custom sesClient was injected via WithClient that is not an *ses.Client.

func (*Service) Close

func (s *Service) Close() error

Close marks the service as closed.

func (*Service) Init

func (s *Service) Init() error

Init validates the configuration and creates the SES client.

func (*Service) Name

func (s *Service) Name() string

Name returns the service identifier.

func (*Service) Send

func (s *Service) Send(ctx context.Context, msg *gas.Email) error

Send sends an email using AWS SES.

func (*Service) SendFromTemplate

func (s *Service) SendFromTemplate(ctx context.Context, msg *gas.TemplatedEmail) error

SendFromTemplate renders email templates and sends the resulting email using AWS SES. It fetches raw template content from the TemplateProvider, parses it, and executes it with the provided data.

type Settings

type Settings struct {
	// Region is the AWS region for the SES service.
	Region string

	// Endpoint is an optional custom endpoint URL (e.g. for LocalStack).
	// Empty means use the default AWS endpoint.
	Endpoint string

	// FromEmail is the default sender email address.
	FromEmail string

	// AccessKeyID is the AWS access key ID for static credentials.
	// If empty, the default AWS credential chain is used.
	AccessKeyID string

	// SecretAccessKey is the AWS secret access key for static credentials.
	// If empty, the default AWS credential chain is used.
	SecretAccessKey string
}

Settings represents the configuration for the SES email service.

Jump to

Keyboard shortcuts

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