ses

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 29 Imported by: 0

README

SES

Parity grade: A · SDK aws-sdk-go-v2/service/ses@v1.34.20 · last audited 2026-07-23 (a40e7cc1)

Coverage

Metric Value
Operations audited 71 (70 ok, 1 partial)
Feature families 11 (11 ok)
Known gaps 6
Deferred items 1
Resource leaks clean
Known gaps
  • GetSendStatistics Bounces/Complaints/Rejects always report 0 — no bounce/complaint event simulation exists in this backend (bd: gopherstack-uve)
  • LimitExceededException never returned — no per-resource count caps modeled (max receipt rules/templates/filters etc.) (bd: gopherstack-ssk)
  • MailFromDomainNotVerifiedException never triggers — SetIdentityMailFromDomain instantly marks Success, consistent with this service's instant-verify convention everywhere else (VerifyEmailIdentity/VerifyDomainIdentity/VerifyDomainDkim all skip the real Pending window too); deliberately not changed to avoid an inconsistent one-off Pending state (bd: gopherstack-nbp)
  • MaxSendRate (per-second) advertised via GetSendQuota but not enforced, only the 24h quota is now enforced (bd: gopherstack-a6y)
  • SendRawEmailInput.FromArn (cross-account sending-authorization ARN for the raw message's From: header, distinct from SourceArn/ReturnPathArn) is not captured -- SendRawEmail delegates to the shared SendEmail backend path which has no concept of a separate From identity from Source, and no sending-authorization is enforced anywhere in this backend regardless. Low value to model without a real cross-account primitive elsewhere in gopherstack; left unimplemented rather than half-modeled (bd: none filed, tracked here).
  • SendTemplatedEmailInput/SendBulkTemplatedEmailInput.TemplateArn (cross-account template reference) is not captured -- Template remains a required member on both real inputs regardless of TemplateArn, and this backend (like the rest of gopherstack's SES emulation) has no cross-account resource model, so accepting-but-ignoring the field would be indistinguishable from today's behavior of simply not reading it. Left unimplemented (bd: none filed, tracked here).
Deferred
  • services/sesv2/ — separate REST-JSON service, out of scope this pass per task constraints (bd: gopherstack-029)

More

Documentation

Index

Constants

View Source
const (
	ReceiptActionTypeS3        = "S3"
	ReceiptActionTypeSNS       = "SNS"
	ReceiptActionTypeLambda    = "Lambda"
	ReceiptActionTypeSQS       = "SQS"
	ReceiptActionTypeAddHeader = "AddHeader"
	ReceiptActionTypeBounce    = "Bounce"
	ReceiptActionTypeStop      = "Stop"
)
View Source
const (
	FilterPolicyAllow = "Allow"
	FilterPolicyBlock = "Block"
	TLSPolicyOptional = "Optional"
	TLSPolicyRequire  = "Require"
)

Variables

View Source
var (
	ErrEmailNotFound               = errors.New("EmailNotFound")
	ErrInvalidParameter            = errors.New("InvalidParameterValue")
	ErrInvalidPolicy               = errors.New("InvalidPolicy")
	ErrMessageRejected             = errors.New("MessageRejected")
	ErrTemplateNotFound            = errors.New("TemplateDoesNotExist")
	ErrTemplateExists              = errors.New("AlreadyExists")
	ErrConfigSetNotFound           = errors.New("ConfigurationSetDoesNotExist")
	ErrConfigSetExists             = errors.New("ConfigurationSetAlreadyExists")
	ErrReceiptRuleSetNotFound      = errors.New("RuleSetDoesNotExist")
	ErrReceiptRuleSetExists        = errors.New("AlreadyExists")
	ErrReceiptRuleSetActive        = errors.New("CannotDelete")
	ErrReceiptRuleNotFound         = errors.New("RuleDoesNotExist")
	ErrReceiptRuleExists           = errors.New("AlreadyExists")
	ErrReceiptFilterNotFound       = errors.New("FilterDoesNotExist")
	ErrReceiptFilterExists         = errors.New("AlreadyExists")
	ErrEventDestinationNotFound    = errors.New("EventDestinationDoesNotExist")
	ErrEventDestinationExists      = errors.New("EventDestinationAlreadyExists")
	ErrTrackingOptionsNotFound     = errors.New("TrackingOptionsDoesNotExistException")
	ErrTrackingOptionsExists       = errors.New("TrackingOptionsAlreadyExistsException")
	ErrCustomVerifTemplateNotFound = errors.New("CustomVerificationEmailTemplateDoesNotExist")
	ErrCustomVerifTemplateExists   = errors.New("CustomVerificationEmailTemplateAlreadyExists")
	ErrValidation                  = errors.New("ValidationError")
	// ErrAccountSendingPaused is returned by send operations when account-level
	// sending has been paused via UpdateAccountSendingEnabled(false), matching
	// real AWS SES's AccountSendingPausedException.
	ErrAccountSendingPaused = errors.New("AccountSendingPausedException")
)

Errors returned by the SES backend.

ErrTrackingOptionsNotFound / ErrTrackingOptionsExists deliberately carry the "Exception"-suffixed wire error codes (TrackingOptionsDoesNotExistException / TrackingOptionsAlreadyExistsException) even though every sibling *DoesNotExist / *AlreadyExists error in this list omits the suffix -- this asymmetry is not a typo, it is what aws-sdk-go-v2/service/ses/types/errors.go's TrackingOptions{DoesNotExist,AlreadyExists}Exception.ErrorCode() literally returns, confirmed against the SDK's deserializers.go error-code switch (case strings.EqualFold("TrackingOptionsDoesNotExistException", errorCode)). Sending the unsuffixed form (as this file did before this pass) causes a real AWS SDK client's error deserializer to miss the typed-exception match.

View Source
var ErrNilAppContext = errors.New("ses: AppContext is nil")

ErrNilAppContext is returned by Init when the AppContext is nil.

Functions

This section is empty.

Types

type BulkEmailDestination

type BulkEmailDestination struct {
	ReplacementTemplateData string
	To                      []string
	Cc                      []string
	Bcc                     []string
	ReplacementTags         []Tag
}

BulkEmailDestination is a single destination entry for SendBulkTemplatedEmail. ReplacementTags mirrors the real SendBulkTemplatedEmailInput BulkEmailDestination.ReplacementTags member: when non-empty it overrides the request-level SendBulkTemplatedEmailInput.DefaultTags for this destination's stored Email record.

type ConfigProvider

type ConfigProvider interface {
	GetSESSettings() Settings
}

ConfigProvider is a private interface to extract SES configuration from the abstract AppContext Config.

type ConfigurationSet

type ConfigurationSet struct {
	// Name is the configuration set name this value is keyed by in the
	// configSets Table (see store_setup.go). Tagged json:"-" for the same
	// reason as IdentityRecord.Identity -- see its doc comment.
	Name              string `json:"-"`
	TLSPolicy         string `json:"tlsPolicy,omitempty"`
	SendingEnabled    bool   `json:"sendingEnabled"`
	ReputationMetrics bool   `json:"reputationMetrics"`
}

ConfigurationSet stores per-configuration-set state.

type ConfigurationSetDescription

type ConfigurationSetDescription struct {
	TrackingOptions          *TrackingOptions
	DeliveryOptions          *DeliveryOptions
	Name                     string
	EventDestinations        []EventDestination
	SendingEnabled           bool
	ReputationMetricsEnabled bool
}

ConfigurationSetDescription holds full details of a configuration set.

type CustomVerificationEmailTemplate

type CustomVerificationEmailTemplate struct {
	TemplateName          string `json:"templateName"`
	FromEmailAddress      string `json:"fromEmailAddress"`
	TemplateSubject       string `json:"templateSubject"`
	TemplateContent       string `json:"templateContent"`
	SuccessRedirectionURL string `json:"successRedirectionURL"`
	FailureRedirectionURL string `json:"failureRedirectionURL"`
}

CustomVerificationEmailTemplate represents a custom verification email template.

type DeliveryOptions

type DeliveryOptions struct {
	TLSPolicy string `json:"tlsPolicy,omitempty"`
}

DeliveryOptions holds the delivery options for a configuration set.

type DkimAttributes

type DkimAttributes struct {
	DkimVerificationStatus string
	DkimTokens             []string
	DkimEnabled            bool
}

DkimAttributes holds DKIM verification attributes for an identity.

type Email

type Email struct {
	Tags                 []Tag     `json:"tags,omitempty"`
	Timestamp            time.Time `json:"timestamp"`
	From                 string    `json:"from"`
	Subject              string    `json:"subject"`
	BodyHTML             string    `json:"bodyHTML"`
	BodyText             string    `json:"bodyText"`
	MessageID            string    `json:"messageID"`
	ConfigurationSetName string    `json:"configurationSetName,omitempty"`
	ReturnPath           string    `json:"returnPath,omitempty"`
	ReturnPathArn        string    `json:"returnPathArn,omitempty"`
	SourceArn            string    `json:"sourceArn,omitempty"`
	To                   []string  `json:"to"`
	Cc                   []string  `json:"cc,omitempty"`
	Bcc                  []string  `json:"bcc,omitempty"`
	ReplyTo              []string  `json:"replyTo,omitempty"`
}

Email captures a sent email for local inspection.

type EmailTemplate

type EmailTemplate struct {
	TemplateName string `json:"templateName"`
	SubjectPart  string `json:"subjectPart"`
	TextPart     string `json:"textPart"`
	HTMLPart     string `json:"htmlPart"`
}

EmailTemplate represents a stored SES email template.

type EventDestination

type EventDestination struct {
	// ConfigSetName is the parent configuration set name. Combined with Name
	// it forms the composite key ("<ConfigSetName>#<Name>", see
	// eventDestinationKey in store_setup.go) the flattened eventDestinations
	// Table is keyed by -- this Table replaces what was previously a nested
	// map[string]map[string]*EventDestination. Tagged json:"-" for the same
	// reason as IdentityRecord.Identity -- see its doc comment.
	ConfigSetName      string   `json:"-"`
	Name               string   `json:"name"`
	SNSTopicARN        string   `json:"snsTopicARN,omitempty"`
	MatchingEventTypes []string `json:"matchingEventTypes"`
	Enabled            bool     `json:"enabled"`
}

EventDestination represents a configuration set event destination.

type Handler

type Handler struct {
	Backend StorageBackend
	// contains filtered or unexported fields
}

Handler is the Echo HTTP handler for SES operations.

func NewHandler

func NewHandler(backend StorageBackend) *Handler

NewHandler creates a new SES handler with the given backend and logger.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns all regions this SES instance handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation extracts the SES action from the request body.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the source email address or identity from the request.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations returns the list of supported SES operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler function for SES requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority for the SES handler.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all in-memory state. Used by the POST /_gopherstack/reset endpoint.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher returns a function that matches SES requests. SES requests are form-encoded POSTs containing Version=2010-12-01 and an action from the SES supported operations list. We check both the version and action to avoid routing conflicts with Elastic Beanstalk, which also uses Version=2010-12-01 but with a disjoint set of action names.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context)

Shutdown stops the janitor worker and waits for it to exit.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker starts the background janitor if configured.

func (*Handler) WithJanitor

func (h *Handler) WithJanitor(interval time.Duration, taskTimeout ...time.Duration) *Handler

WithJanitor attaches a background janitor to the handler. The janitor periodically evicts emails older than the backend TTL. interval=0 uses the default interval. The optional taskTimeout bounds each sweep; 0 means no per-task timeout.

type IdentityRecord

type IdentityRecord struct {
	// Identity is the address or domain this record is keyed by in the
	// identities Table (see store_setup.go). It is tagged json:"-" because
	// the identities Table is a "dirty" table -- persistence.go instead
	// round-trips it through a dedicated identitySnapshot DTO that carries
	// the identity as a real JSON field, so it survives the round trip
	// despite being excluded here. It must never change after the record is
	// created (store.Table's keyFn purity requirement).
	Identity           string   `json:"-"`
	DeliveryTopic      string   `json:"deliveryTopic,omitempty"`
	MailFromDomain     string   `json:"mailFromDomain,omitempty"`
	MailFromStatus     string   `json:"mailFromStatus,omitempty"`
	BehaviorOnMXFail   string   `json:"behaviorOnMXFailure,omitempty"`
	BounceTopic        string   `json:"bounceTopic,omitempty"`
	ComplaintTopic     string   `json:"complaintTopic,omitempty"`
	DkimTokens         []string `json:"dkimTokens,omitempty"`
	DkimEnabled        bool     `json:"dkimEnabled"`
	ForwardingEnabled  bool     `json:"forwardingEnabled"`
	HeadersInBounce    bool     `json:"headersInBounce"`
	HeadersInComplaint bool     `json:"headersInComplaint"`
	HeadersInDelivery  bool     `json:"headersInDelivery"`
	Verified           bool     `json:"verified"`
}

IdentityRecord stores per-identity verification and attribute state.

type InMemoryBackend

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

InMemoryBackend is an in-memory store for SES emails, verified identities, email templates, and configuration sets.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates a new InMemoryBackend with the default email TTL.

func (*InMemoryBackend) AccountID

func (b *InMemoryBackend) AccountID() string

AccountID returns the simulated AWS account ID.

func (*InMemoryBackend) CloneReceiptRuleSet

func (b *InMemoryBackend) CloneReceiptRuleSet(originalName, newName string) error

CloneReceiptRuleSet creates a copy of an existing receipt rule set under a new name.

func (*InMemoryBackend) CreateConfigurationSet

func (b *InMemoryBackend) CreateConfigurationSet(name string) error

CreateConfigurationSet registers a new configuration set. Returns ErrConfigSetExists if it already exists.

func (*InMemoryBackend) CreateConfigurationSetEventDestination

func (b *InMemoryBackend) CreateConfigurationSetEventDestination(configSetName string, dest EventDestination) error

CreateConfigurationSetEventDestination adds an event destination to a configuration set.

func (*InMemoryBackend) CreateConfigurationSetTrackingOptions

func (b *InMemoryBackend) CreateConfigurationSetTrackingOptions(configSetName, customRedirectDomain string) error

CreateConfigurationSetTrackingOptions sets the tracking options for a configuration set.

func (*InMemoryBackend) CreateCustomVerificationEmailTemplate

func (b *InMemoryBackend) CreateCustomVerificationEmailTemplate(tmpl CustomVerificationEmailTemplate) error

CreateCustomVerificationEmailTemplate creates a custom verification email template.

func (*InMemoryBackend) CreateReceiptFilter

func (b *InMemoryBackend) CreateReceiptFilter(filter ReceiptFilter) error

CreateReceiptFilter creates a new IP-based receipt filter.

func (*InMemoryBackend) CreateReceiptRule

func (b *InMemoryBackend) CreateReceiptRule(ruleSetName string, rule ReceiptRule, after string) error

CreateReceiptRule adds a new rule to an existing receipt rule set.

func (*InMemoryBackend) CreateReceiptRuleSet

func (b *InMemoryBackend) CreateReceiptRuleSet(name string) error

CreateReceiptRuleSet creates a new receipt rule set. Returns ErrReceiptRuleSetExists if it already exists.

func (*InMemoryBackend) CreateTemplate

func (b *InMemoryBackend) CreateTemplate(tmpl EmailTemplate) error

CreateTemplate stores a new email template. Returns ErrTemplateExists if the name is taken.

func (*InMemoryBackend) DeleteConfigurationSet

func (b *InMemoryBackend) DeleteConfigurationSet(name string) error

DeleteConfigurationSet removes a configuration set. Returns ErrConfigSetNotFound if the set does not exist, matching real AWS SES behavior.

func (*InMemoryBackend) DeleteConfigurationSetEventDestination

func (b *InMemoryBackend) DeleteConfigurationSetEventDestination(configSetName, destName string) error

DeleteConfigurationSetEventDestination removes an event destination from a configuration set.

func (*InMemoryBackend) DeleteConfigurationSetTrackingOptions

func (b *InMemoryBackend) DeleteConfigurationSetTrackingOptions(configSetName string) error

DeleteConfigurationSetTrackingOptions removes the tracking options from a configuration set.

func (*InMemoryBackend) DeleteCustomVerificationEmailTemplate

func (b *InMemoryBackend) DeleteCustomVerificationEmailTemplate(templateName string) error

DeleteCustomVerificationEmailTemplate removes a custom verification email template.

func (*InMemoryBackend) DeleteIdentity

func (b *InMemoryBackend) DeleteIdentity(identity string)

DeleteIdentity removes a verified identity. This is idempotent — deleting a non-existent identity returns success, matching real AWS SES behavior.

func (*InMemoryBackend) DeleteIdentityPolicy

func (b *InMemoryBackend) DeleteIdentityPolicy(identity, policyName string) error

DeleteIdentityPolicy removes a sending authorization policy from an identity. Deleting a non-existent policy is idempotent.

func (*InMemoryBackend) DeleteReceiptFilter

func (b *InMemoryBackend) DeleteReceiptFilter(name string) error

DeleteReceiptFilter removes a receipt filter by name.

func (*InMemoryBackend) DeleteReceiptRule

func (b *InMemoryBackend) DeleteReceiptRule(ruleSetName, ruleName string) error

DeleteReceiptRule removes a receipt rule from a rule set.

func (*InMemoryBackend) DeleteReceiptRuleSet

func (b *InMemoryBackend) DeleteReceiptRuleSet(name string) error

DeleteReceiptRuleSet removes a receipt rule set and its rules. Matching real AWS SES ("The currently active rule set cannot be deleted."), deleting the currently active rule set is rejected with ErrReceiptRuleSetActive (wire code CannotDelete) rather than silently clearing the active pointer; the caller must first call SetActiveReceiptRuleSet with a different name (or "") before the delete will succeed.

func (*InMemoryBackend) DeleteTemplate

func (b *InMemoryBackend) DeleteTemplate(name string)

DeleteTemplate removes the named template. Idempotent — missing template returns success.

func (*InMemoryBackend) DeleteVerifiedEmailAddress

func (b *InMemoryBackend) DeleteVerifiedEmailAddress(email string)

DeleteVerifiedEmailAddress removes a verified email address (legacy API).

func (*InMemoryBackend) DescribeActiveReceiptRuleSet

func (b *InMemoryBackend) DescribeActiveReceiptRuleSet() (ReceiptRuleSet, bool, error)

DescribeActiveReceiptRuleSet returns the active receipt rule set. Returns false if none is set.

func (*InMemoryBackend) DescribeConfigurationSet

func (b *InMemoryBackend) DescribeConfigurationSet(name string) (ConfigurationSetDescription, error)

DescribeConfigurationSet returns the named configuration set metadata plus event destinations and tracking options.

func (*InMemoryBackend) DescribeReceiptRule

func (b *InMemoryBackend) DescribeReceiptRule(ruleSetName, ruleName string) (ReceiptRule, error)

DescribeReceiptRule returns a named rule from a rule set.

func (*InMemoryBackend) DescribeReceiptRuleSet

func (b *InMemoryBackend) DescribeReceiptRuleSet(name string) (ReceiptRuleSet, error)

DescribeReceiptRuleSet returns a deep copy of the named rule set.

func (*InMemoryBackend) GetAccountSendingEnabled

func (b *InMemoryBackend) GetAccountSendingEnabled() bool

GetAccountSendingEnabled returns the account-level sending enabled flag.

func (*InMemoryBackend) GetCustomVerificationEmailTemplate

func (b *InMemoryBackend) GetCustomVerificationEmailTemplate(
	templateName string,
) (CustomVerificationEmailTemplate, error)

GetCustomVerificationEmailTemplate returns the named custom verification email template.

func (*InMemoryBackend) GetEmailByID

func (b *InMemoryBackend) GetEmailByID(messageID string) (Email, error)

GetEmailByID returns the email with the given MessageID in O(1) time, or an error if not found.

func (*InMemoryBackend) GetIdentityDkimAttributes

func (b *InMemoryBackend) GetIdentityDkimAttributes(identities []string) map[string]DkimAttributes

GetIdentityDkimAttributes returns DKIM attributes for each identity. Known identities return their persisted DKIM state; unknown identities return NotStarted.

func (*InMemoryBackend) GetIdentityMailFromDomainAttributes

func (b *InMemoryBackend) GetIdentityMailFromDomainAttributes(identities []string) map[string]MailFromDomainAttributes

GetIdentityMailFromDomainAttributes returns MailFrom attributes for each identity. Identities with a configured MailFromDomain return Success; others return an empty status.

func (*InMemoryBackend) GetIdentityNotificationAttributes

func (b *InMemoryBackend) GetIdentityNotificationAttributes(identities []string) map[string]NotificationAttributes

GetIdentityNotificationAttributes returns notification attributes for each identity.

func (*InMemoryBackend) GetIdentityPolicies

func (b *InMemoryBackend) GetIdentityPolicies(identity string, policyNames []string) (map[string]string, error)

GetIdentityPolicies returns the policy documents for the given identity filtered by name. An empty policyNames list returns all policies for the identity.

func (*InMemoryBackend) GetIdentityVerificationAttributes

func (b *InMemoryBackend) GetIdentityVerificationAttributes(identities []string) map[string]string

GetIdentityVerificationAttributes returns verification status for each requested identity. Verified identities return Success; unknown identities return NotStarted.

func (*InMemoryBackend) GetSendQuota

func (b *InMemoryBackend) GetSendQuota() SendQuota

GetSendQuota returns simulated quota values. SentLast24Hours counts only emails sent within the past 24 hours.

func (*InMemoryBackend) GetSendStatistics

func (b *InMemoryBackend) GetSendStatistics() []SendDataPoint

GetSendStatistics returns aggregated send data points (one per hour) for the last 14 days, matching real AWS SES behavior.

func (*InMemoryBackend) GetTemplate

func (b *InMemoryBackend) GetTemplate(name string) (EmailTemplate, error)

GetTemplate returns the named template or ErrTemplateNotFound.

func (*InMemoryBackend) ListConfigurationSets

func (b *InMemoryBackend) ListConfigurationSets(nextToken string, maxItems int) page.Page[string]

ListConfigurationSets returns configuration set names sorted alphabetically.

func (*InMemoryBackend) ListCustomVerificationEmailTemplates

func (b *InMemoryBackend) ListCustomVerificationEmailTemplates() []CustomVerificationEmailTemplate

ListCustomVerificationEmailTemplates returns a sorted slice of all custom verification email templates.

func (*InMemoryBackend) ListEmails

func (b *InMemoryBackend) ListEmails() []Email

ListEmails returns a copy of all captured emails.

func (*InMemoryBackend) ListIdentities

func (b *InMemoryBackend) ListIdentities(nextToken string, maxItems int) page.Page[string]

ListIdentities returns a paginated list of registered identities sorted alphabetically.

func (*InMemoryBackend) ListIdentityPolicies

func (b *InMemoryBackend) ListIdentityPolicies(identity string) ([]string, error)

ListIdentityPolicies returns the names of sending authorization policies for an identity.

func (*InMemoryBackend) ListReceiptFilters

func (b *InMemoryBackend) ListReceiptFilters() []ReceiptFilter

ListReceiptFilters returns a sorted slice of all receipt filters.

func (*InMemoryBackend) ListReceiptRuleSets

func (b *InMemoryBackend) ListReceiptRuleSets() []ReceiptRuleSet

ListReceiptRuleSets returns a sorted slice of all receipt rule sets (name + createdAt only).

func (*InMemoryBackend) ListTemplates

func (b *InMemoryBackend) ListTemplates(nextToken string, maxItems int) page.Page[string]

ListTemplates returns template names sorted alphabetically, with pagination.

func (*InMemoryBackend) ListVerifiedEmailAddresses

func (b *InMemoryBackend) ListVerifiedEmailAddresses() []string

ListVerifiedEmailAddresses returns all verified identities that are email addresses (contain @).

func (*InMemoryBackend) PutConfigurationSetDeliveryOptions

func (b *InMemoryBackend) PutConfigurationSetDeliveryOptions(configSetName, tlsPolicy string) error

PutConfigurationSetDeliveryOptions persists the TLS policy for a configuration set.

func (*InMemoryBackend) PutIdentityPolicy

func (b *InMemoryBackend) PutIdentityPolicy(identity, policyName, policy string) error

PutIdentityPolicy stores a sending authorization policy for an identity. Real AWS SES validates that Policy is a well-formed JSON IAM-style policy document and rejects malformed input with InvalidPolicyException; this backend does not evaluate policy semantics (no sending-authorization enforcement exists anywhere in this emulator), but it does reject non-JSON input the same way, matching the wire error code.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the AWS region for this backend instance.

func (*InMemoryBackend) ReorderReceiptRuleSet

func (b *InMemoryBackend) ReorderReceiptRuleSet(ruleSetName string, ruleNames []string) error

ReorderReceiptRuleSet reorders the rules in a rule set according to the given ordered name list.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all in-memory state, restoring the backend to its initial empty state. The configured email TTL (set via WithEmailTTL) is preserved.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) SearchEmails

func (b *InMemoryBackend) SearchEmails(query string) []Email

SearchEmails returns emails whose From, Subject, or To fields contain the given query string (case-insensitive). This provides O(n) filtered access while leveraging the existing email slice.

func (*InMemoryBackend) SendBounce

func (b *InMemoryBackend) SendBounce(originalMsgID, bounceSender string, recipients []string) (string, error)

SendBounce generates and sends a bounce message for a previously received email. Real AWS SES models BounceSender and BouncedRecipientInfoList as required input members (SendBounceInput), so both must be supplied here; BounceSender must additionally be a verified identity (or a verified domain), matching the same sender-verification rule enforced by SendEmail.

func (*InMemoryBackend) SendBulkTemplatedEmail

func (b *InMemoryBackend) SendBulkTemplatedEmail(in SendBulkTemplatedEmailInput) ([]string, error)

SendBulkTemplatedEmail sends one email per destination and returns a message ID for each. Each destination is rendered with the request-level DefaultTemplateData merged with that destination's ReplacementTemplateData, matching AWS SES SendBulkTemplatedEmail semantics where replacement values override defaults on a per-recipient basis. ConfigurationSetName, ReplyTo, ReturnPath, ReturnPathArn and SourceArn mirror the corresponding SendBulkTemplatedEmailInput members and are threaded through to every generated Email record exactly as SendEmail/SendTemplatedEmail do for a single-destination send. Message tags follow the same per-destination override pattern as template data: a destination's ReplacementTags, when non-empty, is used in place of (not merged with) the request-level DefaultTags for that destination's stored Email record.

func (*InMemoryBackend) SendCustomVerificationEmail

func (b *InMemoryBackend) SendCustomVerificationEmail(
	email, templateName, configurationSetName string,
) (string, error)

SendCustomVerificationEmail adds email to the account's identity list and attempts to verify it (matching this backend's instant-verification convention shared by VerifyEmailIdentity/VerifyEmailAddress) and sends a verification email using the named custom template. templateName must reference an existing custom verification email template (CreateCustomVerificationEmailTemplate), and configurationSetName, if supplied, must reference an existing configuration set — both required preconditions on the real AWS SES SendCustomVerificationEmailInput.

func (*InMemoryBackend) SendEmail

func (b *InMemoryBackend) SendEmail(in SendEmailInput) (string, error)

SendEmail captures an outbound email and returns a message ID. The source address must be a verified identity or from a verified domain (matching real AWS SES behavior).

func (*InMemoryBackend) SendTemplatedEmail

func (b *InMemoryBackend) SendTemplatedEmail(in SendTemplatedEmailInput) (string, error)

SendTemplatedEmail sends an email using a stored template and returns the message ID. The source address must be a verified identity or from a verified domain. The template must already exist; ErrTemplateNotFound is returned otherwise.

func (*InMemoryBackend) SetActiveReceiptRuleSet

func (b *InMemoryBackend) SetActiveReceiptRuleSet(name string) error

SetActiveReceiptRuleSet sets the named rule set as active. Passing an empty name clears the active rule set.

func (*InMemoryBackend) SetIdentityDkimEnabled

func (b *InMemoryBackend) SetIdentityDkimEnabled(identity string, enabled bool) error

SetIdentityDkimEnabled persists the DKIM-enabled flag for an identity.

func (*InMemoryBackend) SetIdentityFeedbackForwardingEnabled

func (b *InMemoryBackend) SetIdentityFeedbackForwardingEnabled(identity string, enabled bool) error

SetIdentityFeedbackForwardingEnabled persists the forwarding-enabled flag for an identity.

func (*InMemoryBackend) SetIdentityHeadersInNotificationsEnabled

func (b *InMemoryBackend) SetIdentityHeadersInNotificationsEnabled(
	identity, notificationType string, enabled bool,
) error

SetIdentityHeadersInNotificationsEnabled persists the header-inclusion flag for an identity and notification type (Bounce, Complaint, or Delivery).

func (*InMemoryBackend) SetIdentityMailFromDomain

func (b *InMemoryBackend) SetIdentityMailFromDomain(identity, mailFromDomain, behaviorOnMXFailure string) error

SetIdentityMailFromDomain persists the custom MAIL FROM domain for an identity. An empty mailFromDomain clears the setting (and its BehaviorOnMXFailure). behaviorOnMXFailure must be "UseDefaultValue" or "RejectMessage"; an empty value defaults to "UseDefaultValue", matching real AWS SES.

func (*InMemoryBackend) SetIdentityNotificationTopic

func (b *InMemoryBackend) SetIdentityNotificationTopic(identity, notificationType, snsTopic string) error

SetIdentityNotificationTopic persists the SNS notification topic for an identity and notification type (Bounce, Complaint, or Delivery).

func (*InMemoryBackend) SetReceiptRulePosition

func (b *InMemoryBackend) SetReceiptRulePosition(ruleSetName, ruleName string, position int) error

SetReceiptRulePosition moves a rule to the given zero-based position in a rule set.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) TestRenderTemplate

func (b *InMemoryBackend) TestRenderTemplate(templateName, templateData string) (string, error)

TestRenderTemplate renders the named template with the given JSON template data. Variable substitution uses {{key}} syntax matching AWS SES Handlebars-style templating.

func (*InMemoryBackend) UpdateAccountSendingEnabled

func (b *InMemoryBackend) UpdateAccountSendingEnabled(enabled bool)

UpdateAccountSendingEnabled persists the account-level sending enabled flag.

func (*InMemoryBackend) UpdateConfigurationSetEventDestination

func (b *InMemoryBackend) UpdateConfigurationSetEventDestination(configSetName string, dest EventDestination) error

UpdateConfigurationSetEventDestination updates an existing event destination on a configuration set.

func (*InMemoryBackend) UpdateConfigurationSetReputationMetricsEnabled

func (b *InMemoryBackend) UpdateConfigurationSetReputationMetricsEnabled(configSetName string, enabled bool) error

UpdateConfigurationSetReputationMetricsEnabled persists the reputation metrics flag.

func (*InMemoryBackend) UpdateConfigurationSetSendingEnabled

func (b *InMemoryBackend) UpdateConfigurationSetSendingEnabled(configSetName string, enabled bool) error

UpdateConfigurationSetSendingEnabled persists the sending-enabled flag.

func (*InMemoryBackend) UpdateConfigurationSetTrackingOptions

func (b *InMemoryBackend) UpdateConfigurationSetTrackingOptions(configSetName, customRedirectDomain string) error

UpdateConfigurationSetTrackingOptions updates the tracking options for a configuration set.

func (*InMemoryBackend) UpdateCustomVerificationEmailTemplate

func (b *InMemoryBackend) UpdateCustomVerificationEmailTemplate(tmpl CustomVerificationEmailTemplate) error

UpdateCustomVerificationEmailTemplate updates an existing custom verification email template.

func (*InMemoryBackend) UpdateReceiptRule

func (b *InMemoryBackend) UpdateReceiptRule(ruleSetName string, rule ReceiptRule) error

UpdateReceiptRule replaces an existing rule in a rule set.

func (*InMemoryBackend) UpdateTemplate

func (b *InMemoryBackend) UpdateTemplate(tmpl EmailTemplate) error

UpdateTemplate overwrites an existing template. Returns ErrTemplateNotFound if it does not exist.

func (*InMemoryBackend) VerifyDomainDkim

func (b *InMemoryBackend) VerifyDomainDkim(domain string) ([]string, error)

VerifyDomainDkim adds a domain as a verified identity and returns deterministic DKIM tokens.

func (*InMemoryBackend) VerifyDomainIdentity

func (b *InMemoryBackend) VerifyDomainIdentity(domain string) (string, error)

VerifyDomainIdentity adds a domain as a verified identity, returning a deterministic verification token.

func (*InMemoryBackend) VerifyEmailAddress

func (b *InMemoryBackend) VerifyEmailAddress(email string) error

VerifyEmailAddress is an alias for VerifyEmailIdentity (legacy API).

func (*InMemoryBackend) VerifyEmailIdentity

func (b *InMemoryBackend) VerifyEmailIdentity(identity string) error

VerifyEmailIdentity adds an identity (address or domain) and marks it as verified. If the identity already exists its verified flag is updated without clearing other attributes.

func (*InMemoryBackend) WithAccountID

func (b *InMemoryBackend) WithAccountID(accountID string) *InMemoryBackend

WithAccountID sets the AWS account ID for this backend instance and returns it for chaining.

func (*InMemoryBackend) WithEmailTTL

func (b *InMemoryBackend) WithEmailTTL(ttl time.Duration) *InMemoryBackend

WithEmailTTL sets the TTL for stored sent emails and returns the backend for chaining. Zero falls back to the default TTL. The configured TTL is preserved across Reset() calls.

func (*InMemoryBackend) WithRegion

func (b *InMemoryBackend) WithRegion(region string) *InMemoryBackend

WithRegion sets the AWS region for this backend instance and returns it for chaining.

type Janitor

type Janitor struct {
	Backend     *InMemoryBackend
	Interval    time.Duration
	TaskTimeout time.Duration
}

Janitor is the SES background worker that evicts emails older than the configured TTL to prevent unbounded memory and persistence growth.

func NewJanitor

func NewJanitor(backend *InMemoryBackend, interval time.Duration) *Janitor

NewJanitor creates a new SES Janitor for the given backend. A zero interval falls back to defaultSESJanitorInterval.

func (*Janitor) Run

func (j *Janitor) Run(ctx context.Context)

Run runs the janitor loop until ctx is cancelled.

func (*Janitor) SweepOnce

func (j *Janitor) SweepOnce(ctx context.Context)

SweepOnce executes a single TTL sweep. Exposed for testing.

type MailFromDomainAttributes

type MailFromDomainAttributes struct {
	MailFromDomain       string
	MailFromDomainStatus string
	BehaviorOnMXFailure  string
}

MailFromDomainAttributes holds MailFrom domain attributes for an identity.

type NotificationAttributes

type NotificationAttributes struct {
	BounceTopic        string
	ComplaintTopic     string
	DeliveryTopic      string
	ForwardingEnabled  bool
	HeadersInBounce    bool
	HeadersInComplaint bool
	HeadersInDelivery  bool
}

NotificationAttributes holds notification topic attributes for an identity.

type Provider

type Provider struct{}

Provider implements service.Provider for the SES service.

func (*Provider) Init

Init initializes the SES service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the logical name of the provider.

type ReceiptAction

type ReceiptAction struct {
	Type              string `json:"type"`
	S3BucketName      string `json:"s3BucketName,omitempty"`
	S3KeyPrefix       string `json:"s3KeyPrefix,omitempty"`
	S3TopicARN        string `json:"s3TopicARN,omitempty"`
	SNSTopicARN       string `json:"snsTopicARN,omitempty"`
	LambdaFunctionARN string `json:"lambdaFunctionARN,omitempty"`
	LambdaTopicARN    string `json:"lambdaTopicARN,omitempty"`
	SQSQueueARN       string `json:"sqsQueueARN,omitempty"`
	SQSTopicARN       string `json:"sqsTopicARN,omitempty"`
	HeaderName        string `json:"headerName,omitempty"`
	HeaderValue       string `json:"headerValue,omitempty"`
	SMTPReplyCode     string `json:"smtpReplyCode,omitempty"`
	StatusCode        string `json:"statusCode,omitempty"`
	Message           string `json:"message,omitempty"`
	Sender            string `json:"sender,omitempty"`
	BounceTopicARN    string `json:"bounceTopicARN,omitempty"`
}

ReceiptAction is a single action within a receipt rule. Type identifies which action fields apply: S3, SNS, Lambda, SQS, AddHeader, Bounce, Stop.

type ReceiptFilter

type ReceiptFilter struct {
	Name   string `json:"name"`
	Policy string `json:"policy"`
	CIDR   string `json:"cidr"`
}

ReceiptFilter represents an IP-based receipt filter.

type ReceiptRule

type ReceiptRule struct {
	Name        string          `json:"name"`
	TLSPolicy   string          `json:"tlsPolicy"`
	Recipients  []string        `json:"recipients"`
	Actions     []ReceiptAction `json:"actions,omitempty"`
	Enabled     bool            `json:"enabled"`
	ScanEnabled bool            `json:"scanEnabled"`
}

ReceiptRule represents a single receipt rule within a rule set.

type ReceiptRuleSet

type ReceiptRuleSet struct {
	Name      string        `json:"name"`
	CreatedAt time.Time     `json:"createdAt"`
	Rules     []ReceiptRule `json:"rules"`
}

ReceiptRuleSet represents an SES receipt rule set.

type SendBulkTemplatedEmailInput added in v1.2.0

type SendBulkTemplatedEmailInput struct {
	Source               string
	TemplateName         string
	DefaultTemplateData  string
	ConfigurationSetName string
	ReturnPath           string
	ReturnPathArn        string
	SourceArn            string
	ReplyTo              []string
	DefaultTags          []Tag
	Destinations         []BulkEmailDestination
}

SendBulkTemplatedEmailInput contains all parameters for SendBulkTemplatedEmail, mirroring aws-sdk-go-v2/service/ses's SendBulkTemplatedEmailInput. DefaultTags is applied to every destination's stored Email record unless overridden by that destination's BulkEmailDestination.ReplacementTags.

type SendDataPoint

type SendDataPoint struct {
	Timestamp        time.Time `json:"timestamp"`
	DeliveryAttempts float64   `json:"deliveryAttempts"`
	Bounces          float64   `json:"bounces"`
	Complaints       float64   `json:"complaints"`
	Rejects          float64   `json:"rejects"`
}

SendDataPoint represents a single send statistics time bucket.

type SendEmailInput

type SendEmailInput struct {
	Tags                 []Tag
	From                 string
	Subject              string
	BodyHTML             string
	BodyText             string
	ConfigurationSetName string
	ReturnPath           string
	ReturnPathArn        string
	SourceArn            string
	To                   []string
	Cc                   []string
	Bcc                  []string
	ReplyTo              []string
}

SendEmailInput contains all parameters for sending an email.

type SendQuota

type SendQuota struct {
	Max24HourSend   float64
	MaxSendRate     float64
	SentLast24Hours float64
}

SendQuota holds the simulated SES sending quota values.

type SendTemplatedEmailInput

type SendTemplatedEmailInput struct {
	Tags                 []Tag
	From                 string
	TemplateName         string
	TemplateData         string
	ConfigurationSetName string
	ReturnPath           string
	ReturnPathArn        string
	SourceArn            string
	To                   []string
	Cc                   []string
	Bcc                  []string
	ReplyTo              []string
}

SendTemplatedEmailInput contains all parameters for sending a templated email.

type Settings

type Settings struct {
	JanitorInterval time.Duration `json:"janitor_interval" env:"SES_JANITOR_INTERVAL" default:"1m"  help:"Janitor tick interval."`                              //nolint:lll // Kong struct tag makes this line long
	EmailTTL        time.Duration `json:"email_ttl"        env:"SES_EMAIL_TTL"        default:"24h" help:"TTL for stored sent emails before they are evicted."` //nolint:lll // Kong struct tag makes this line long
}

Settings holds service-level configuration for the SES backend. Fields are picked up by the Kong CLI parser when this struct is embedded in the root CLI command.

type StorageBackend

type StorageBackend interface {
	VerifyEmailIdentity(identity string) error
	DeleteIdentity(identity string)
	ListIdentities(nextToken string, maxItems int) page.Page[string]
	GetIdentityVerificationAttributes(identities []string) map[string]string
	SendEmail(in SendEmailInput) (string, error)
	SendTemplatedEmail(in SendTemplatedEmailInput) (string, error)
	ListEmails() []Email
	GetEmailByID(messageID string) (Email, error)
	SearchEmails(query string) []Email
	CreateTemplate(tmpl EmailTemplate) error
	UpdateTemplate(tmpl EmailTemplate) error
	GetTemplate(name string) (EmailTemplate, error)
	DeleteTemplate(name string)
	ListTemplates(nextToken string, maxItems int) page.Page[string]
	CreateConfigurationSet(name string) error
	DeleteConfigurationSet(name string) error
	ListConfigurationSets(nextToken string, maxItems int) page.Page[string]
	DescribeConfigurationSet(name string) (ConfigurationSetDescription, error)
	PutConfigurationSetDeliveryOptions(configSetName, tlsPolicy string) error
	GetSendQuota() SendQuota
	GetSendStatistics() []SendDataPoint
	CreateReceiptRuleSet(name string) error
	CloneReceiptRuleSet(originalName, newName string) error
	CreateReceiptRule(ruleSetName string, rule ReceiptRule, after string) error
	DescribeReceiptRule(ruleSetName, ruleName string) (ReceiptRule, error)
	UpdateReceiptRule(ruleSetName string, rule ReceiptRule) error
	ReorderReceiptRuleSet(ruleSetName string, ruleNames []string) error
	SetReceiptRulePosition(ruleSetName, ruleName string, position int) error
	CreateReceiptFilter(filter ReceiptFilter) error
	CreateConfigurationSetEventDestination(configSetName string, dest EventDestination) error
	DeleteConfigurationSetEventDestination(configSetName, destName string) error
	UpdateConfigurationSetEventDestination(configSetName string, dest EventDestination) error
	UpdateConfigurationSetReputationMetricsEnabled(configSetName string, enabled bool) error
	UpdateConfigurationSetSendingEnabled(configSetName string, enabled bool) error
	CreateConfigurationSetTrackingOptions(configSetName, customRedirectDomain string) error
	DeleteConfigurationSetTrackingOptions(configSetName string) error
	UpdateConfigurationSetTrackingOptions(configSetName, customRedirectDomain string) error
	CreateCustomVerificationEmailTemplate(tmpl CustomVerificationEmailTemplate) error
	DeleteCustomVerificationEmailTemplate(templateName string) error
	UpdateCustomVerificationEmailTemplate(tmpl CustomVerificationEmailTemplate) error
	ListReceiptFilters() []ReceiptFilter
	ListReceiptRuleSets() []ReceiptRuleSet
	DeleteReceiptFilter(name string) error
	DeleteReceiptRule(ruleSetName, ruleName string) error
	DeleteReceiptRuleSet(name string) error
	GetCustomVerificationEmailTemplate(templateName string) (CustomVerificationEmailTemplate, error)
	ListCustomVerificationEmailTemplates() []CustomVerificationEmailTemplate
	DescribeReceiptRuleSet(name string) (ReceiptRuleSet, error)
	SetActiveReceiptRuleSet(name string) error
	DescribeActiveReceiptRuleSet() (ReceiptRuleSet, bool, error)
	// Identity policy ops
	PutIdentityPolicy(identity, policyName, policy string) error
	DeleteIdentityPolicy(identity, policyName string) error
	GetIdentityPolicies(identity string, policyNames []string) (map[string]string, error)
	ListIdentityPolicies(identity string) ([]string, error)
	// Identity attribute ops
	GetIdentityDkimAttributes(identities []string) map[string]DkimAttributes
	GetIdentityMailFromDomainAttributes(identities []string) map[string]MailFromDomainAttributes
	GetIdentityNotificationAttributes(identities []string) map[string]NotificationAttributes
	SetIdentityDkimEnabled(identity string, enabled bool) error
	SetIdentityFeedbackForwardingEnabled(identity string, enabled bool) error
	SetIdentityHeadersInNotificationsEnabled(identity, notificationType string, enabled bool) error
	SetIdentityMailFromDomain(identity, mailFromDomain, behaviorOnMXFailure string) error
	SetIdentityNotificationTopic(identity, notificationType, snsTopic string) error
	// Domain verification
	VerifyDomainIdentity(domain string) (string, error)
	VerifyDomainDkim(domain string) ([]string, error)
	VerifyEmailAddress(email string) error
	DeleteVerifiedEmailAddress(email string)
	ListVerifiedEmailAddresses() []string
	// Account-level
	UpdateAccountSendingEnabled(enabled bool)
	GetAccountSendingEnabled() bool
	// Send ops
	SendBounce(originalMsgID, bounceSender string, recipients []string) (string, error)
	SendBulkTemplatedEmail(in SendBulkTemplatedEmailInput) ([]string, error)
	SendCustomVerificationEmail(email, templateName, configurationSetName string) (string, error)
	TestRenderTemplate(templateName, templateData string) (string, error)
	Region() string
	AccountID() string
	Reset()
	Snapshot(ctx context.Context) []byte
	Restore(ctx context.Context, data []byte) error
}

StorageBackend defines the persistence contract for the SES service.

type Tag

type Tag struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Tag is an email metadata key-value pair.

type TrackingOptions

type TrackingOptions struct {
	// ConfigSetName is the configuration set name this value is keyed by in
	// the trackingOptions Table (see store_setup.go). Tagged json:"-" for
	// the same reason as IdentityRecord.Identity -- see its doc comment.
	ConfigSetName        string `json:"-"`
	CustomRedirectDomain string `json:"customRedirectDomain"`
}

TrackingOptions represents the tracking options for a configuration set.

Jump to

Keyboard shortcuts

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