ses

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: AGPL-3.0 Imports: 43 Imported by: 0

Documentation

Overview

Package ses is the Amazon SES adapter (SES API v2 through aws-sdk-go-v2), with events delivered through SNS.

Index

Constants

View Source
const (
	TopicName = "reputecast-events"
	// QueueName is the SQS queue of the queue mode (PR-4).
	QueueName = "reputecast-events"
	RoleName  = "ReputeCastSES"
	// EventDestination names the configuration sets' event destination.
	EventDestination = "reputecast"
)

Resource names created by provisioning. A suffix is added when another connection of the same instance already uses them in the account.

View Source
const (
	TagMessage = "rc_message"
	TagStream  = "rc_stream"
)

Tag names SES echoes back on events.

View Source
const Adapter = "ses"

Adapter is the registry key.

View Source
const BatchSize = 50

BatchSize is how many messages one Send call handles (in parallel).

View Source
const Policy = `` /* 760-byte string literal not displayed */

Policy is the least-privilege IAM policy ReputeCast needs.

View Source
const QueueWait = 20 * time.Second

QueueWait is one long poll of the queue: the cadence the setup promises ("polls every 20 s").

View Source
const SimulatorAddress = "success@simulator.amazonses.com"

SimulatorAddress is SES's mailbox simulator: it accepts mail and makes SES report a delivery, without touching the account's bounce or complaint rates.

View Source
const Template = `` /* 2470-byte string literal not displayed */

Template is the CloudFormation template that creates the role.

Variables

View Source
var RegionNames = map[string]string{
	"us-east-1": "N. Virginia", "us-east-2": "Ohio", "us-west-1": "N. California", "us-west-2": "Oregon",
	"ca-central-1": "Canada (Central)", "eu-west-1": "Ireland", "eu-west-2": "London", "eu-west-3": "Paris",
	"eu-central-1": "Frankfurt", "eu-north-1": "Stockholm", "eu-south-1": "Milan", "ap-south-1": "Mumbai",
	"ap-northeast-1": "Tokyo", "ap-northeast-2": "Seoul", "ap-northeast-3": "Osaka", "ap-southeast-1": "Singapore",
	"ap-southeast-2": "Sydney", "sa-east-1": "São Paulo", "me-south-1": "Bahrain", "af-south-1": "Cape Town",
	"il-central-1": "Tel Aviv",
}

RegionNames are the SES regions with the names the AWS console uses.

View Source
var StatusFeedURL = "https://status.aws.amazon.com/rss/ses-%s.rss"

StatusFeedURL is the public AWS status RSS feed for SES in a region. It is read only while a provider is down, to say whether AWS reports an incident.

Functions

func Descriptor

func Descriptor() providers.Descriptor

Descriptor describes the adapter for the catalog.

func New

New builds the adapter. Credentials are resolved lazily by the SDK.

func RolePrincipal

func RolePrincipal(s string) string

RolePrincipal turns an assumed-role session ARN (arn:aws:sts::123:assumed-role/Name/session) into the role ARN a trust policy can name; other ARNs are returned unchanged.

func TenantName

func TenantName(slug, suffix string) string

TenantName is the tenant of a workspace: its slug in the characters SES allows (letters, digits, - and _), at most 64.

func ValidCertURL

func ValidCertURL(u string) bool

ValidCertURL reports whether u may host an SNS signing certificate.

Types

type Credentials

type Credentials struct {
	AccessKeyID     string `json:"access_key_id,omitempty"`
	SecretAccessKey string `json:"secret_access_key,omitempty"`
	SessionToken    string `json:"session_token,omitempty"`
}

Credentials are write-only.

type Envelope

type Envelope struct {
	Type             string `json:"Type"`
	MessageID        string `json:"MessageId"`
	Token            string `json:"Token,omitempty"`
	TopicArn         string `json:"TopicArn"`
	Subject          string `json:"Subject,omitempty"`
	Message          string `json:"Message"`
	Timestamp        string `json:"Timestamp"`
	SignatureVersion string `json:"SignatureVersion"`
	Signature        string `json:"Signature"`
	SigningCertURL   string `json:"SigningCertURL"`
	SubscribeURL     string `json:"SubscribeURL,omitempty"`
	UnsubscribeURL   string `json:"UnsubscribeURL,omitempty"`
}

Envelope is an SNS HTTP(S) message.

func (Envelope) StringToSign

func (e Envelope) StringToSign() string

StringToSign builds the canonical string SNS signs for this message type.

type Provider

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

Provider talks to SES in one region.

func (*Provider) AccessTemplate

AccessTemplate implements providers.AccessTemplater.

func (*Provider) AccountID

func (p *Provider) AccountID(ctx context.Context) (string, error)

AccountID implements providers.AccountIdentifier.

func (*Provider) AckEvents

func (p *Provider) AckEvents(ctx context.Context, handles []string) error

AckEvents implements providers.EventQueue: stored messages leave the queue, ten per call.

func (*Provider) Adapter

func (p *Provider) Adapter() string

Adapter implements providers.Provider.

func (*Provider) AddDomain

func (p *Provider) AddDomain(ctx context.Context, domain string) ([]providers.DNSRecord, error)

AddDomain implements providers.DomainManager: Easy DKIM and a custom MAIL FROM domain (bounce.<domain>), associated with the workspace's tenant.

func (*Provider) AddSuppressions

func (p *Provider) AddSuppressions(ctx context.Context, emails []string) error

AddSuppressions implements providers.SuppressionSyncer as hard bounces. It never writes the account-level list: without a tenant it does nothing and says so (providers.ErrNotSupported).

func (*Provider) AddSuppressionsWithReason

func (p *Provider) AddSuppressionsWithReason(ctx context.Context, list []providers.Suppression) error

AddSuppressionsWithReason implements providers.SuppressionReasonAdder: the tenant's list, a complaint as COMPLAINT and a hard bounce as BOUNCE.

func (*Provider) CallerARN

func (p *Provider) CallerARN() string

CallerARN is who the credentials belong to, as the last AccountID call read it ("arn:aws:iam::123456789012:user/reputecast-ses").

func (*Provider) Capabilities

func (p *Provider) Capabilities() providers.Capabilities

Capabilities implements providers.Provider.

func (*Provider) DisableTracking

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

DisableTracking implements providers.TrackingManager by removing OPEN and CLICK from every event destination of the configuration set.

func (*Provider) DomainStatus

func (p *Provider) DomainStatus(ctx context.Context, domain string) ([]providers.DNSRecord, error)

DomainStatus implements providers.DomainManager.

func (*Provider) EventCheckAddress

func (p *Provider) EventCheckAddress() string

EventCheckAddress implements providers.EventChecker (PR-3).

func (*Provider) EventCheckFrom

func (p *Provider) EventCheckFrom(ctx context.Context, candidates []string) (string, error)

EventCheckFrom implements providers.EventChecker: SES sends only from verified identities, the simulator's mail included.

func (*Provider) Handshake

func (p *Provider) Handshake(ctx context.Context, _ *http.Request, body []byte) (bool, []byte, error)

Handshake implements providers.WebhookHandshaker: it confirms SNS subscriptions to the provider's topic by visiting SubscribeURL.

func (*Provider) ListSuppressions

func (p *Provider) ListSuppressions(ctx context.Context, since time.Time) ([]providers.Suppression, error)

ListSuppressions implements providers.SuppressionSyncer: the tenant's list, or the account-level list without a tenant.

func (*Provider) ParseWebhook

func (p *Provider) ParseWebhook(ctx context.Context, _ *http.Request, body []byte) ([]providers.Event, error)

ParseWebhook implements providers.Provider for SNS notifications.

func (*Provider) Provision

Provision implements providers.Provisioner.

func (*Provider) ProvisionSteps

ProvisionSteps implements providers.Provisioner: the workspace's tenant (PR-11), the event path (SNS calling the webhook, or SNS into an SQS queue ReputeCast polls, PR-4) and a configuration set per stream.

func (*Provider) QueueEnabled

func (p *Provider) QueueEnabled() bool

QueueEnabled implements providers.EventQueue.

func (*Provider) Quota

func (p *Provider) Quota(ctx context.Context) (providers.Quota, error)

Quota implements providers.QuotaReporter from GetAccount.

func (*Provider) ReceiveEvents

func (p *Provider) ReceiveEvents(ctx context.Context, maxEvents int, wait time.Duration) ([]providers.QueuedEvent, error)

ReceiveEvents implements providers.EventQueue: up to max SNS envelopes, each one SES event, waiting up to wait for the first.

func (*Provider) RemoveSuppressions

func (p *Provider) RemoveSuppressions(ctx context.Context, emails []string) error

RemoveSuppressions implements providers.SuppressionRemover on the tenant's list only.

func (*Provider) RequestProductionAccess

func (p *Provider) RequestProductionAccess(ctx context.Context, r providers.ProductionAccessRequest) error

RequestProductionAccess implements providers.ProductionAccessRequester.

func (*Provider) ScanRegions

func (p *Provider) ScanRegions(ctx context.Context) ([]providers.RegionStatus, error)

ScanRegions implements providers.RegionScanner: GetAccount in every SES region, ten at a time.

func (*Provider) Send

func (p *Provider) Send(ctx context.Context, msgs []providers.Message) ([]providers.SendResult, error)

Send implements providers.Provider: SendEmail with raw MIME per message, up to ten at a time. A batch fails as a whole only when every message failed for the same account-level reason (outage, credentials).

func (*Provider) SendWithExtras

func (p *Provider) SendWithExtras(ctx context.Context, msgs []providers.Message, extras []providers.MessageExtras) ([]providers.SendResult, error)

SendWithExtras implements providers.ExtrasSender: copies and attachments (transactional mail) go in the raw message, every recipient in the destination.

func (*Provider) SendingIPs

func (p *Provider) SendingIPs(ctx context.Context) (providers.SendingIPs, error)

SendingIPs implements providers.IPReporter with GetDedicatedIps, every page of it: the dedicated IPs of the account in the connection's region, standard and managed pools alike. An account without any sends from SES's shared pool. Access that can't call it (a role or keys from before ReputeCast asked for ses:GetDedicatedIps) is an error that says what to allow, so the IPs ReputeCast knows stay.

func (*Provider) ServiceStatus

func (p *Provider) ServiceStatus(ctx context.Context) (providers.ServiceStatus, error)

ServiceStatus implements providers.StatusReporter.

func (*Provider) StatusPageURL

func (p *Provider) StatusPageURL() (string, string)

StatusPageURL implements providers.StatusPage.

func (*Provider) SuppressionScope

func (p *Provider) SuppressionScope() providers.SuppressionScope

SuppressionScope implements providers.SuppressionScoper: the tenant's own list when the workspace has a tenant; otherwise the account-level list, which ReputeCast only reads, because every app on the AWS account shares it.

func (*Provider) Tracking

func (p *Provider) Tracking(ctx context.Context) (providers.Tracking, error)

Tracking implements providers.TrackingManager: SES rewrites links and adds an open pixel when the configuration set publishes OPEN or CLICK events.

func (*Provider) Verify

func (p *Provider) Verify(ctx context.Context) (providers.Quota, error)

Verify implements providers.Verifier.

func (*Provider) VerifyWebhook

func (p *Provider) VerifyWebhook(ctx context.Context, _ *http.Request, body []byte) error

VerifyWebhook implements providers.WebhookVerifier.

type Settings

type Settings struct {
	Region           string `json:"region"`
	ConfigurationSet string `json:"configuration_set,omitempty"`
	// ConfigurationSets names a configuration set per stream ("broadcast",
	// "automation", "system"), as provisioned by the connect flow; streams
	// without one use ConfigurationSet.
	ConfigurationSets map[string]string `json:"configuration_sets,omitempty"`
	// Access is "keys" (access key in the credentials) or "role" (assume
	// RoleARN with ExternalID from the instance's own AWS credentials, as
	// set up by the CloudFormation template).
	Access     string `json:"access,omitempty"`
	RoleARN    string `json:"role_arn,omitempty"`
	ExternalID string `json:"external_id,omitempty"`
	// TopicARNs restricts which SNS topics may post events.
	TopicARNs []string `json:"topic_arns,omitempty"`
	// Tenant is the SES tenant of the workspace (PR-11): its own suppression
	// list and reputation, so a bounce in this workspace never stops mail of
	// another workspace or app on the same AWS account. Sends name it.
	Tenant string `json:"tenant,omitempty"`
	// Events is how SES events come back: "" (SNS calls the webhook) or
	// "queue" (an SQS queue ReputeCast polls, PR-4), with the queue's URL
	// and ARN once provisioned.
	Events   string `json:"events,omitempty"`
	QueueURL string `json:"queue_url,omitempty"`
	QueueARN string `json:"queue_arn,omitempty"`
	// AccountID is the AWS account (the tenant's resource ARNs).
	AccountID string `json:"account_id,omitempty"`
	// Endpoint overrides the SES API endpoint (tests, VPC endpoints).
	Endpoint string `json:"endpoint,omitempty"`
}

Settings are the non-secret connection settings.

Jump to

Keyboard shortcuts

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