email

package
v1.20.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Overview

Package email provides the email integration definition for the integrations framework. It supports dual-use: runtime-provisioned ("system owned") for internal platform email (password resets, invites, campaigns, workflow actions) and customer-provisioned for customer-managed email sending via resend, sendgrid, or postmark

Index

Constants

View Source
const (
	// TagCampaignTargetID identifies the campaign target for delivery event correlation
	TagCampaignTargetID = "campaign_target_id"
	// TagAssessmentResponseID identifies the assessment response for delivery event correlation
	TagAssessmentResponseID = "assessment_response_id"
	// TagIsTest marks a message as a test send to prevent cascade updates
	TagIsTest = "is_test"
)

Tag key constants for email delivery tracking via provider webhooks

View Source
const ProviderMock = "mock"

ProviderMock is the provider name for the mock email sender used in tests

Variables

View Source
var (
	// ErrProviderNotSupported indicates the provider string is not a recognized email provider
	ErrProviderNotSupported = errors.New("email: provider not supported")
	// ErrClientBuildFailed indicates the email client could not be constructed
	ErrClientBuildFailed = errors.New("email: client build failed")
	// ErrDispatcherNotFound indicates no registered email dispatcher matches the template key
	ErrDispatcherNotFound = errors.New("email: dispatcher not found for template key")
	// ErrInvalidOperationClient indicates the operation request client is not the expected *Client type
	ErrInvalidOperationClient = errors.New("email: invalid operation client type")
	// ErrTemplateRenderFailed indicates template rendering failed
	ErrTemplateRenderFailed = errors.New("email: template render failed")
	// ErrSendFailed indicates the email provider returned an error during send
	ErrSendFailed = errors.New("email: send failed")
	// ErrEmailTemplateNotFound indicates an email template cannot be found
	ErrEmailTemplateNotFound = errors.New("email: email template not found")
	// ErrCampaignNotFound indicates a campaign cannot be found for email dispatch
	ErrCampaignNotFound = errors.New("email: campaign not found")
	// ErrSenderNotConfigured indicates the email client has no sender configured
	ErrSenderNotConfigured = errors.New("email: sender not configured")
	// ErrCampaignMissingAssessment indicates a questionnaire campaign has no linked assessment
	ErrCampaignMissingAssessment = errors.New("email: campaign has no assessment ID")
	// ErrAssessmentNotFound indicates the assessment linked to a campaign cannot be found
	ErrAssessmentNotFound = errors.New("email: assessment not found")
	// ErrQuestionnaireDispatchFailed indicates failure during dispatch of a questionnaire access email to a campaign target
	ErrQuestionnaireDispatchFailed = errors.New("email: questionnaire dispatch failed")
)
View Source
var (
	_, VerifyEmailOp = providerkit.OperationSchema[VerifyEmailRequest]()
	_,//nolint:revive
	WelcomeOp = providerkit.OperationSchema[WelcomeRequest]()
	_,//nolint:revive
	InviteOp = providerkit.OperationSchema[InviteRequest]()
	_,//nolint:revive
	InviteJoinedOp = providerkit.OperationSchema[InviteJoinedRequest]()
	_,//nolint:revive
	ResetRequestOp = providerkit.OperationSchema[PasswordResetEmailRequest]()
	_,//nolint:revive
	ResetSuccessOp = providerkit.OperationSchema[PasswordResetSuccessRequest]()
	_,//nolint:revive
	SubscribeOp = providerkit.OperationSchema[SubscribeRequest]()
	_,//nolint:revive
	VerifyBillingOp = providerkit.OperationSchema[VerifyBillingRequest]()
	_,//nolint:revive
	TCNDARequestOp = providerkit.OperationSchema[TrustCenterNDARequestEmail]()
	_,//nolint:revive
	TCNDASignedOp = providerkit.OperationSchema[TrustCenterNDASignedEmail]()
	_,//nolint:revive
	TCAuthOp = providerkit.OperationSchema[TrustCenterAuthEmail]()
	_,//nolint:revive
	QuestionnaireAuthOp = providerkit.OperationSchema[QuestionnaireAuthEmail]()
	_,//nolint:revive
	BillingEmailChangedOp = providerkit.OperationSchema[BillingEmailChangedEmail]() //nolint:revive
)
View Source
var (
	// DefinitionID is the stable identifier for the email integration definition
	DefinitionID = types.NewDefinitionRef("def_01EMAILINT00000000000000001")
	_,// sendEmailSchema is the operation schema for the generic send-email operation
	SendEmailOp = providerkit.OperationSchema[SendEmailRequest]()
	_,//nolint:revive
	// sendBrandedCampaignSchema is the operation schema for the branded campaign dispatch operation
	SendCampaignOp = providerkit.OperationSchema[SendBrandedCampaignRequest]()
	_,//nolint:revive
	// sendQuestionnaireCampaignSchema is the operation schema for the questionnaire campaign dispatch operation
	SendQuestionnaireCampaignOp = providerkit.OperationSchema[SendQuestionnaireCampaignRequest]() //nolint:revive
)
View Source
var DefaultSocial = []SocialLink{
	{Platform: "Openlane", IconURL: "https://www.theopenlane.io/cdn-cgi/imagedelivery/2gi-D0CFOlSOflWJG-LQaA/b8653f6d-71ed-4f90-937c-361192079100/w=36", URL: "https://www.theopenlane.io"},
	{Platform: "GitHub", IconURL: "https://react-email-demo-fsxo0305n-resend.vercel.app/static/shared/social-gh-black.png", URL: "https://github.com/theopenlane"},
	{Platform: "LinkedIn", IconURL: "https://react-email-demo-fsxo0305n-resend.vercel.app/static/shared/social-in-black.png", URL: "https://linkedin.com/company/theopenlane"},
}

DefaultSocial is the default set of social footer links applied to runtime email configs when no explicit social links are provided

EmailHTMLScrubber is the shared scrubber instance used by email providers for render-time HTML sanitization, preserving email-safe layout elements while stripping dangerous content

View Source
var (
	_, BrandedMessageOp = providerkit.OperationSchema[BrandedMessageRequest]() //nolint:revive
)

brandedMessageSchema is the reflected JSON schema for the branded message input type and BrandedMessageOp is the typed operation ref used for catalog dispatch

Functions

func AllEmailOperations

func AllEmailOperations() []types.OperationRegistration

AllEmailOperations returns all system email operation registrations for wiring into the builder

func Builder

func Builder(cfg *RuntimeEmailConfig) registry.Builder

Builder returns the email definition builder with the supplied runtime config applied. When cfg.Provisioned() is true, a RuntimeIntegration is included for system-send. Customer registrations (credentials, connections, clients, user input) are always present

func EmailScrubber

func EmailScrubber() scrubber.Scrubber

EmailScrubber returns the shared HTML scrubber instance used for email content sanitization. This is the canonical sanitization policy for both storage-time and render-time email HTML processing

func MockSenderFromClient

func MockSenderFromClient(client any) *mock.EmailSender

MockSenderFromClient extracts the *mock.EmailSender from an Client. Returns nil if the sender is not a mock

func SetDefaultTrustCenterDomain

func SetDefaultTrustCenterDomain(domain string)

SetDefaultTrustCenterDomain sets the fallback domain for trust center URLs

func TargetDispatchable

func TargetDispatchable(status enums.AssessmentResponseStatus, sentAt *models.DateTime, resend bool, includeOverdue bool) bool

TargetDispatchable reports whether a campaign target should be included in a dispatch attempt for the requested action semantics

func TemplateVariables

func TemplateVariables() []models.TemplateVariable

TemplateVariables returns all system-provided template variables available to email template authors: config-backed fields, payload fields, and computed values

func TestFixture

func TestFixture(name, toEmail string) json.RawMessage

TestFixture returns a scaffolded JSON payload for the given dispatcher name. All required fields are populated with realistic test values; URL-resolved fields (NDAURL, AuthURL) are set directly so PreHooks that require a database are bypassed. Returns nil when no fixture is defined for the dispatcher

Types

type BillingEmailChangedEmail

type BillingEmailChangedEmail struct {
	RecipientInfo
	// OrgName is the organization whose billing email changed
	OrgName string `json:"org_name" jsonschema:"required,description=Organization name"`
	// OldBillingEmail is the previous billing email address
	OldBillingEmail string `json:"old_billing_email" jsonschema:"required,description=Previous billing email"`
	// NewBillingEmail is the new billing email address
	NewBillingEmail string `json:"new_billing_email" jsonschema:"required,description=New billing email"`
	// ChangedAt is the timestamp of the change
	ChangedAt time.Time `json:"changed_at" jsonschema:"required,description=Timestamp of the change"`
}

BillingEmailChangedEmail is the input for the billing email change notification

type BrandedMessageRequest

type BrandedMessageRequest struct {
	RecipientInfo
	CampaignContext
	// Subject is the email subject line
	Subject string `json:"subject" jsonschema:"required,description=Email subject line"`
	// Preheader is hidden preview text shown in the inbox list
	Preheader string `json:"preheader,omitempty" jsonschema:"description=Inbox preview text"`
	// Title is the headline shown above the body paragraphs
	Title string `json:"title" jsonschema:"required,description=Email headline"`
	// Intros are body paragraphs rendered before the optional call-to-action button
	Intros []string `json:"intros,omitempty" jsonschema:"description=Body paragraphs rendered before the call-to-action"`
	// ButtonText is the optional call-to-action button label
	ButtonText string `json:"buttonText,omitempty" jsonschema:"description=Call-to-action button label"`
	// ButtonLink is the URL the call-to-action button navigates to
	ButtonLink string `json:"buttonLink,omitempty" jsonschema:"description=Call-to-action button URL"`
	// Outros are fine-print paragraphs rendered after the call-to-action
	Outros []string `json:"outros,omitempty" jsonschema:"description=Fine-print paragraphs rendered after the call-to-action"`
	// LogoURL overrides the hero logo displayed in the email body for this send
	LogoURL string `json:"logoURL,omitempty" jsonschema:"description=Hero logo URL override for this send"`
	// HeaderLogoURL overrides the small logo/icon in the top header bar for this send
	HeaderLogoURL string `json:"headerLogoURL,omitempty" jsonschema:"description=Header bar logo/icon URL override for this send"`
	// PrimaryColor overrides the headline/emphasis color for this send
	PrimaryColor string `json:"primaryColor,omitempty" jsonschema:"description=Primary headline color override (hex)"`
	// BodyBackgroundColor overrides the outer page background color for this send
	BodyBackgroundColor string `json:"bodyBackgroundColor,omitempty" jsonschema:"description=Outer page background color override (hex)"`
	// CardBackgroundColor overrides the card container background color for this send
	CardBackgroundColor string `json:"cardBackgroundColor,omitempty" jsonschema:"description=Card container background color override (hex)"`
	// HeroBackgroundColor overrides the hero banner background color for this send
	HeroBackgroundColor string `json:"heroBackgroundColor,omitempty" jsonschema:"description=Hero banner background color override (hex)"`
	// ButtonColor overrides the call-to-action button background color for this send
	ButtonColor string `json:"buttonColor,omitempty" jsonschema:"description=CTA button background color override (hex)"`
	// ButtonTextColor overrides the call-to-action button text color for this send
	ButtonTextColor string `json:"buttonTextColor,omitempty" jsonschema:"description=CTA button text color override (hex)"`
	// TextColor overrides the body paragraph text color for this send
	TextColor string `json:"textColor,omitempty" jsonschema:"description=Body text color override (hex)"`
	// FooterTextColor overrides the muted text color for this send
	FooterTextColor string `json:"footerTextColor,omitempty" jsonschema:"description=Muted text color override (hex)"`
}

BrandedMessageRequest is a customer-selectable catalog entry providing a flexible, brand-themed email shape. Customers supply the subject, headline, body paragraphs, and optional call-to-action; the base theme handles layout, branding, and footer chrome

type CampaignContext

type CampaignContext struct {
	// CampaignID is the identifier of the campaign producing the send
	CampaignID string `json:"campaignId,omitempty" jsonschema:"description=Campaign identifier"`
	// CampaignName is the display name of the campaign
	CampaignName string `json:"campaignName,omitempty" jsonschema:"description=Campaign display name"`
	// CampaignDescription is the long-form description of the campaign
	CampaignDescription string `json:"campaignDescription,omitempty" jsonschema:"description=Campaign description"`
	// CampaignDueDate is the response deadline for the campaign, formatted for display
	CampaignDueDate string `json:"campaignDueDate,omitempty" jsonschema:"description=Campaign response due date"`
}

CampaignContext carries campaign-scoped metadata for catalog entries that render campaign-bound emails. Entries that need campaign fields embed this struct in their input type; the campaign dispatcher populates the JSON overlay before calling SendByKey

type CampaignDispatchInput

type CampaignDispatchInput struct {
	// CampaignID is the identifier of the campaign to dispatch
	CampaignID string `json:"campaignId" jsonschema:"required,description=Campaign identifier"`
	// Resend allows previously sent, incomplete targets to receive another message
	Resend bool `json:"resend,omitempty" jsonschema:"description=Whether to include previously sent targets"`
	// IncludeOverdue includes overdue targets when dispatching incomplete recipients
	IncludeOverdue bool `json:"includeOverdue,omitempty" jsonschema:"description=Whether overdue targets should be included"`
}

CampaignDispatchInput holds the shared dispatch parameters for campaign operations

type CampaignDispatchResult

type CampaignDispatchResult struct {
	// SentCount is the number of messages successfully sent
	SentCount int `json:"sentCount"`
	// SkippedCount is the number of targets skipped (already sent, completed, filtered)
	SkippedCount int `json:"skippedCount"`
	// FailedCount is the number of targets that failed to render or send
	FailedCount int `json:"failedCount"`
}

CampaignDispatchResult is the structured result returned by campaign operations

type Client

type Client struct {
	// Sender is the configured email provider client
	Sender newman.EmailSender
	// Config holds branding and URL configuration for template rendering
	Config RuntimeEmailConfig
}

Client wraps a newman.EmailSender with the RuntimeEmailConfig needed for template rendering and branding

type Credential

type Credential struct {
	// APIKey is the email provider API key
	APIKey string `json:"apiKey" jsonschema:"required,description=Email provider API key"`
	// Provider is the email service provider name
	Provider string `json:"provider" jsonschema:"required,enum=resend,enum=sendgrid,enum=postmark,description=Email service provider"`
}

Credential is the credential schema for customer-provisioned email

type Dispatcher

type Dispatcher interface {
	// Name returns the catalog key identifying the dispatcher
	Name() string
	// Registration returns the integration operation registration for this entry
	Registration() types.OperationRegistration
	// SendByKey decodes the payload into the entry's typed input, runs any registered PreHook,
	// and dispatches through the shared render/send pipeline. Additional newman options are
	// appended after the operation's own MessageOptions
	SendByKey(ctx context.Context, req types.OperationRequest, client *Client, payload json.RawMessage, extraOpts ...newman.MessageOption) error
	// RenderMessage decodes the payload and renders the email into a newman message without sending it, for use in batch send paths
	RenderMessage(ctx context.Context, client *Client, payload json.RawMessage, extraOpts ...newman.MessageOption) (*newman.EmailMessage, error)
}

Dispatcher describes a catalog-addressable email operation that can be invoked by key The implementation owns typed decoding of the payload and projection into render.EmailContent; callers supply a raw JSON payload whose shape matches the registered input type

func CustomerSelectableDispatchers

func CustomerSelectableDispatchers() []Dispatcher

CustomerSelectableDispatchers returns the dispatchers explicitly marked as customer-selectable

func DispatcherByKey

func DispatcherByKey(key string) (Dispatcher, bool)

DispatcherByKey resolves a registered email dispatcher by its catalog key

type HealthCheck

type HealthCheck struct{}

HealthCheck validates that the email provider credentials are functional by verifying the sender is configured and reachable

func (HealthCheck) Handle

func (h HealthCheck) Handle() types.OperationHandler

Handle returns the typed operation handler for builder registration

func (HealthCheck) Run

func (HealthCheck) Run(_ context.Context, client *Client) (json.RawMessage, error)

Run validates the email client is configured with a working sender

type InviteJoinedRequest

type InviteJoinedRequest struct {
	RecipientInfo
	// OrgName is the organization the user joined
	OrgName string `json:"org_name" jsonschema:"required,description=Organization name"`
}

InviteJoinedRequest is the input for the invite-accepted notification

type InviteRequest

type InviteRequest struct {
	RecipientInfo
	// InviterName is the name of the person who sent the invite
	InviterName string `json:"inviter_name" jsonschema:"required,description=Name of the person sending the invite"`
	// OrgName is the organization being invited to
	OrgName string `json:"org_name" jsonschema:"required,description=Organization name"`
	// Role is the invited role
	Role string `json:"role,omitempty" jsonschema:"description=Invited role"`
	// Token is the invite token appended to the invite URL
	Token string `json:"token" jsonschema:"required,description=Invite token"`
}

InviteRequest is the input for the organization invite operation

type Operation

type Operation[T Recipient] struct {
	// Op is the typed operation ref with name derived from the schema definition key
	Op types.OperationRef[T]
	// Schema is the reflected JSON schema for the input type
	Schema json.RawMessage
	// Description is the human-readable summary shown in the catalog picker
	Description string
	// CustomerSelectable gates whether the entry is exposed via the customer-facing catalog query
	CustomerSelectable *bool
	// Subject returns the rendered subject line for the email
	Subject func(cfg RuntimeEmailConfig, input T) string
	// Theme is the newman render theme applied to this email
	Theme *render.Theme
	// Build returns the structured body content for newman rendering
	Build func(cfg RuntimeEmailConfig, input T) render.ContentBody
	// Config is an optional per-op override for the installation config
	Config func(cfg RuntimeEmailConfig, input T) RuntimeEmailConfig
	// MessageOptions returns additional newman message options for per-operation customization such as attachment
	MessageOptions func(cfg RuntimeEmailConfig, input T) []newman.MessageOption
	// PreHook is an optional hook invoked before rendering to resolve dynamic fields
	PreHook func(ctx context.Context, req types.OperationRequest, input *T) error
}

Operation is a generic helper which defines a single system email type as a registered integration operation this allows us to do AllEmailOperations() in the builder rather than manually wiring each

func RegisterEmailOperation

func RegisterEmailOperation[T Recipient](op Operation[T]) Operation[T]

RegisterEmailOperation constructs an Operation[T] and adds it to the dispatcher registry

func (Operation[T]) Name

func (e Operation[T]) Name() string

Name returns the catalog key for the operation, satisfying the Dispatcher interface

func (Operation[T]) Registration

func (e Operation[T]) Registration() types.OperationRegistration

Registration returns the types.OperationRegistration for wiring into the definition builder. Catalog-facing fields (Description, CustomerSelectable) travel on the registration so downstream filters (e.g. customer-facing catalog query) can operate on AllEmailOperations directly

func (Operation[T]) RenderMessage

func (e Operation[T]) RenderMessage(_ context.Context, client *Client, payload json.RawMessage, extraOpts ...newman.MessageOption) (*newman.EmailMessage, error)

RenderMessage decodes the payload and renders the email into a newman message without sending it

func (Operation[T]) SendByKey

func (e Operation[T]) SendByKey(ctx context.Context, req types.OperationRequest, client *Client, payload json.RawMessage, extraOpts ...newman.MessageOption) error

SendByKey decodes the payload into T and dispatches through the shared render pipeline

type PasswordResetEmailRequest

type PasswordResetEmailRequest struct {
	RecipientInfo
	// Token is the password reset token appended to the reset URL
	Token string `json:"token" jsonschema:"required,description=Password reset token"`
}

PasswordResetEmailRequest is the input for the password reset request operation

type PasswordResetSuccessRequest

type PasswordResetSuccessRequest struct {
	RecipientInfo
}

PasswordResetSuccessRequest is the input for the password reset confirmation operation

type QuestionnaireAuthEmail

type QuestionnaireAuthEmail struct {
	RecipientInfo
	// AssessmentName is the name of the assessment/questionnaire
	AssessmentName string `json:"assessment_name" jsonschema:"required,description=Assessment name"`
	// AuthURL is the authentication URL for questionnaire access
	AuthURL string `json:"auth_url" jsonschema:"required,description=Questionnaire auth URL"`
}

QuestionnaireAuthEmail is the input for questionnaire access authentication

type Recipient

type Recipient interface {
	// GetRecipient returns the RecipientInfo
	GetRecipient() RecipientInfo
}

Recipient is implemented by all email operation input types to provide recipient information

type RecipientInfo

type RecipientInfo struct {
	// Email is the recipient email address
	Email string `json:"email" jsonschema:"required,description=Recipient email address"`
	// FirstName is the recipient first name
	FirstName string `json:"firstName,omitempty" jsonschema:"description=Recipient first name"`
	// LastName is the recipient last name
	LastName string `json:"lastName,omitempty" jsonschema:"description=Recipient last name"`
	// Tags are delivery tracking tags forwarded to the email provider for webhook correlation
	Tags []newman.Tag `json:"tags,omitempty" jsonschema:"description=Delivery tracking tags"`
}

RecipientInfo holds recipient addressing fields embedded in every email operation input

func TestRecipient

func TestRecipient(toEmail string) RecipientInfo

TestRecipient returns a RecipientInfo with the given email and placeholder name fields

func (RecipientInfo) GetRecipient

func (r RecipientInfo) GetRecipient() RecipientInfo

GetRecipient returns the recipient info, satisfying the Recipient interface

type RuntimeEmailConfig

type RuntimeEmailConfig struct {
	// APIKey is the email provider API key
	APIKey string `json:"apiKey" koanf:"apiKey" jsonschema:"required,description=Email provider API key"`
	// Provider is the email service provider name (resend, sendgrid, postmark)
	Provider string `` /* 146-byte string literal not displayed */
	// FromEmail is the default sender email address
	FromEmail string `` /* 127-byte string literal not displayed */
	// SupportEmail is the support contact email address
	SupportEmail string `` /* 128-byte string literal not displayed */
	// QuestionnaireEmail is an optional sender override for questionnaire auth emails
	QuestionnaireEmail string `` /* 171-byte string literal not displayed */
	// RootURL is the root application URL used to construct email action links
	RootURL string `` /* 150-byte string literal not displayed */
	// ProductURL is the product home URL
	ProductURL string `json:"productURL" koanf:"productURL" jsonschema:"description=Product home URL" default:"https://console.theopenlane.io"`
	// DocsURL is the documentation URL
	DocsURL string `json:"docsURL" koanf:"docsURL" jsonschema:"description=Documentation URL" default:"https://docs.theopenlane.io"`
	// CompanyName is the display name of the sending company
	CompanyName string `json:"companyName" jsonschema:"description=Company display name" default:"Openlane"`
	// CompanyAddress is the mailing address of the company
	CompanyAddress string `json:"companyAddress" jsonschema:"description=Company mailing address" default:""`
	// Corporation is the legal corporation name
	Corporation string `json:"corporation" jsonschema:"description=Legal corporation name" default:"theopenlane, Inc."`
	// LogoURL is the hero logo image URL displayed prominently in the email body
	LogoURL string `json:"logoURL,omitempty" jsonschema:"description=Hero logo URL displayed in the email body"`
	// HeaderLogoURL is the small logo/icon displayed in the top header bar
	HeaderLogoURL string `` /* 243-byte string literal not displayed */
	// Copyright is an optional copyright override for email footers; when empty the template renders © {year} {corporation}
	Copyright string `` /* 176-byte string literal not displayed */
	// TroubleText is the fallback help text shown below action buttons; {ACTION} is replaced with button text at render time
	TroubleText string `` /* 271-byte string literal not displayed */
	// TermsURL is the terms of service link for email footers
	TermsURL string `` /* 150-byte string literal not displayed */
	// PrivacyURL is the privacy policy link for email footers
	PrivacyURL string `` /* 141-byte string literal not displayed */
	// UnsubscribeURL is an optional unsubscribe link override for email footers; when empty the template constructs one from ProductURL and the recipient email
	UnsubscribeURL string `` /* 180-byte string literal not displayed */
	// HeaderText is the optional text displayed in the upper-right corner of the modern theme header row
	HeaderText string `json:"headerText,omitempty" jsonschema:"description=Text displayed in the upper-right corner of the modern theme header"`
	// CardStyle controls the card visual style; elevated adds rounded corners and a drop shadow
	CardStyle string `json:"cardStyle,omitempty" jsonschema:"enum=flat,enum=elevated,description=Card visual style" default:"elevated"`
	// BodyBackgroundColor is the outer page background color
	BodyBackgroundColor string `json:"bodyBackgroundColor,omitempty" jsonschema:"description=Outer page background color" default:"#e8eaed"`
	// CardBackgroundColor is the card container background color
	CardBackgroundColor string `json:"cardBackgroundColor,omitempty" jsonschema:"description=Card container background color" default:"#ffffff"`
	// HeroBackgroundColor is the hero banner section background color
	HeroBackgroundColor string `json:"heroBackgroundColor,omitempty" jsonschema:"description=Hero banner section background color" default:"#f3f4f6"`
	// ButtonColor is the call-to-action button background color
	ButtonColor string `json:"buttonColor,omitempty" jsonschema:"description=Call-to-action button background color" default:"#14171e"`
	// ButtonTextColor is the call-to-action button text color
	ButtonTextColor string `json:"buttonTextColor,omitempty" jsonschema:"description=Call-to-action button text color" default:"#ffffff"`
	// HeadingColor is the heading and title text color
	HeadingColor string `json:"headingColor,omitempty" jsonschema:"description=Heading and title text color" default:"#14171e"`
	// TextColor is the body paragraph text color
	TextColor string `json:"textColor,omitempty" jsonschema:"description=Body paragraph text color" default:"#43454b"`
	// FooterTextColor is the muted text color for headers, footers, and secondary content
	FooterTextColor string `` /* 134-byte string literal not displayed */
	// Tagline is a short descriptive footer line rendered in modern themes above the social row
	Tagline string `` /* 126-byte string literal not displayed */
	// Social is the ordered list of social footer entries rendered by modern themes
	Social []SocialLink `json:"social,omitempty" jsonschema:"-"`
}

RuntimeEmailConfig is the complete config for runtime-provisioned email. Operational fields (API key, provider, URLs) are sourced from koanf/environment at startup. Branding and presentation fields carry struct-tag defaults only and are overridable per-send via UserInput or per-operation Config functions

func MockRuntimeConfig

func MockRuntimeConfig() *RuntimeEmailConfig

MockRuntimeConfig returns a RuntimeEmailConfig backed by the mock provider for use in integration test suites

func (RuntimeEmailConfig) Provisioned

func (c RuntimeEmailConfig) Provisioned() bool

Provisioned reports whether the runtime config has the minimum required fields to build a working email client (API key, provider, and from address)

type SendBrandedCampaign

type SendBrandedCampaign struct{}

SendBrandedCampaign dispatches templated branded emails to all pending campaign targets

func (SendBrandedCampaign) Handle

Handle returns the typed operation handler for builder registration

func (SendBrandedCampaign) Run

Run loads the campaign and pending targets, renders all messages, then sends via batch API or rate-limited individual sends depending on whether attachments are present. Returns a marshaled CampaignDispatchResult with counts

type SendBrandedCampaignRequest

type SendBrandedCampaignRequest struct {
	CampaignDispatchInput
}

SendBrandedCampaignRequest is the operation config for dispatching a branded email campaign

type SendEmail

type SendEmail struct{}

SendEmail dispatches a single templated email through the resolved email client

func (SendEmail) Handle

func (s SendEmail) Handle() types.OperationHandler

Handle returns the typed operation handler for builder registration

func (SendEmail) Run

Run resolves the email template, looks up the catalog dispatcher by Key, builds a typed payload from the template defaults + per-invocation recipient, and sends through the dispatcher

type SendEmailRequest

type SendEmailRequest struct {
	// TemplateID references the email template by database ID
	TemplateID string `json:"templateId" jsonschema:"required,description=Email template ID"`
	// OwnerID is the organization owner for template resolution
	OwnerID string `json:"ownerId" jsonschema:"required,description=Organization owner ID"`
	// To is the recipient email address
	To string `json:"to" jsonschema:"required,description=Recipient email address"`
	// Tags are delivery metadata tags for provider webhook correlation
	Tags []newman.Tag `json:"tags,omitempty" jsonschema:"description=Delivery tracking tags"`
	// From is an optional sender address override
	From string `json:"from,omitempty" jsonschema:"description=Sender email address override"`
	// ReplyTo is an optional reply-to address
	ReplyTo string `json:"replyTo,omitempty" jsonschema:"description=Reply-to email address"`
}

SendEmailRequest is the operation config for dispatching a single templated email. The template is resolved by database ID; its Key selects the catalog entry that owns the render pipeline and its Defaults supplies the pre-filled typed fields

type SendQuestionnaireCampaign

type SendQuestionnaireCampaign struct{}

SendQuestionnaireCampaign dispatches questionnaire access emails to all pending campaign targets, creating assessment responses and generating anonymous access tokens for each recipient

func (SendQuestionnaireCampaign) Handle

Handle returns the typed operation handler for builder registration

func (SendQuestionnaireCampaign) Run

Run loads the campaign and its assessment, iterates pending targets, creates assessment responses, generates anonymous JWT access tokens, and sends questionnaire access emails

type SendQuestionnaireCampaignRequest

type SendQuestionnaireCampaignRequest struct {
	CampaignDispatchInput
	// TestEmail dispatches a single test questionnaire email without adding a campaign target
	TestEmail string `json:"testEmail,omitempty" jsonschema:"description=Recipient email for a test questionnaire send"`
}

SendQuestionnaireCampaignRequest is the operation config for dispatching a questionnaire campaign

type SocialLink struct {
	// Platform is the display label for the social network (e.g. X, LinkedIn)
	Platform string `json:"platform" koanf:"platform" jsonschema:"required,description=Display label for the social network"`
	// IconURL is the publicly reachable URL of the icon image
	IconURL string `json:"iconURL" koanf:"iconURL" jsonschema:"required,description=Publicly reachable icon image URL"`
	// URL is the destination the icon links to
	URL string `json:"url" koanf:"url" jsonschema:"required,description=Destination URL the icon links to"`
}

SocialLink is a single social media footer entry: platform label, icon image URL, and destination URL

type SubscribeRequest

type SubscribeRequest struct {
	RecipientInfo
	// OrgName is the display name of the subscribing organization
	OrgName string `json:"org_name" jsonschema:"required,description=Organization display name"`
	// Token is the subscriber verification token appended to the verify URL
	Token string `json:"token" jsonschema:"required,description=Subscriber verification token"`
}

SubscribeRequest is the input for the subscription verification operation

type TargetSendFunc

type TargetSendFunc func(ctx context.Context, target *generated.CampaignTarget) error

TargetSendFunc is per-target callback invoked by dispatchCampaignTargets for each dispatchable target

type TrustCenterAuthEmail

type TrustCenterAuthEmail struct {
	RecipientInfo
	// OrgName is the organization whose trust center is being accessed; resolved from TrustCenterID when empty
	OrgName string `json:"org_name,omitempty" jsonschema:"description=Organization name"`
	// RequestID is the NDA request identifier used for JWT subject construction
	RequestID string `json:"requestId,omitempty" jsonschema:"description=NDA request ID for token generation"`
	// TrustCenterID is the trust center identifier used for URL construction
	TrustCenterID string `json:"trustCenterId,omitempty" jsonschema:"description=Trust center ID for URL construction"`
	// AuthURL is the authentication URL for trust center access; when empty the operation constructs it from RequestID and TrustCenterID
	AuthURL string `json:"authUrl,omitempty" jsonschema:"description=Trust center auth URL"`
}

TrustCenterAuthEmail is the input for trust center access authentication. Callers may pass either the pre-built AuthURL or the RequestID + TrustCenterID pair; when AuthURL is empty the operation resolves it from RequestID and TrustCenterID. OrgName is resolved from TrustCenterID when empty

type TrustCenterNDARequestEmail

type TrustCenterNDARequestEmail struct {
	RecipientInfo
	// OrgName is the organization requesting the NDA; resolved from TrustCenterID when empty
	OrgName string `json:"org_name,omitempty" jsonschema:"description=Organization name"`
	// RequestID is the NDA request identifier used for JWT subject construction
	RequestID string `json:"requestId,omitempty" jsonschema:"description=NDA request ID for token generation"`
	// TrustCenterID is the trust center identifier used for URL construction
	TrustCenterID string `json:"trustCenterId,omitempty" jsonschema:"description=Trust center ID for URL construction"`
	// NDAURL is the direct URL to the NDA signing page; when empty the operation constructs it from RequestID and TrustCenterID
	NDAURL string `json:"ndaUrl,omitempty" jsonschema:"description=NDA signing URL"`
}

TrustCenterNDARequestEmail is the input for the trust center NDA signing request. Callers may pass either the pre-built NDAURL or the RequestID + TrustCenterID pair; when NDAURL is empty the operation resolves it from RequestID and TrustCenterID. OrgName is resolved from TrustCenterID when empty

type TrustCenterNDASignedEmail

type TrustCenterNDASignedEmail struct {
	RecipientInfo
	// OrgName is the organization whose NDA was signed
	OrgName string `json:"org_name" jsonschema:"required,description=Organization name"`
	// TrustCenterURL is the URL to the trust center
	TrustCenterURL string `json:"trust_center_url" jsonschema:"required,description=Trust center URL"`
	// AttachmentFilename is the filename for the signed NDA attachment
	AttachmentFilename string `json:"attachment_filename,omitempty" jsonschema:"description=Signed NDA attachment filename"`
	// AttachmentData is the raw content of the signed NDA attachment
	AttachmentData []byte `json:"attachment_data,omitempty" jsonschema:"description=Signed NDA attachment content"`
}

TrustCenterNDASignedEmail is the input for the NDA signed confirmation

type UserInput

type UserInput struct {
	// FromEmail is the default sender email address
	FromEmail string `json:"fromEmail" jsonschema:"required,description=Default sender email address"`
	// CompanyName is the display name used in email templates
	CompanyName string `json:"companyName" jsonschema:"required,description=Company display name for email templates"`
	// CompanyAddress is the mailing address for CAN-SPAM compliance
	CompanyAddress string `json:"companyAddress,omitempty" jsonschema:"description=Company mailing address"`
	// Corporation is the legal corporation name
	Corporation string `json:"corporation,omitempty" jsonschema:"description=Legal corporation name"`
	// SupportEmail is the support contact email address
	SupportEmail string `json:"supportEmail,omitempty" jsonschema:"description=Support contact email address"`
	// LogoURL is the hero logo URL displayed prominently in the email body
	LogoURL string `json:"logoURL,omitempty" jsonschema:"description=Hero logo URL displayed in the email body"`
	// HeaderLogoURL is the small logo/icon displayed in the top header bar
	HeaderLogoURL string `json:"headerLogoURL,omitempty" jsonschema:"description=Small logo or icon displayed in the top header bar"`
	// RootURL is the root application URL used to construct email action links
	RootURL string `json:"rootURL,omitempty" jsonschema:"description=Root application URL"`
	// ProductURL is the product home URL
	ProductURL string `json:"productURL,omitempty" jsonschema:"description=Product home URL"`
	// DocsURL is the documentation URL
	DocsURL string `json:"docsURL,omitempty" jsonschema:"description=Documentation URL"`
	// Copyright is the copyright notice for email footers
	Copyright string `` /* 139-byte string literal not displayed */
	// TroubleText is the fallback help text shown below action buttons
	TroubleText string `json:"troubleText,omitempty" jsonschema:"description=Help text shown below action buttons"`
	// UnsubscribeURL is the unsubscribe link for email footers
	UnsubscribeURL string `json:"unsubscribeURL,omitempty" jsonschema:"description=Unsubscribe URL for email footers"`
	// Tagline is a short descriptive footer line rendered in modern themes above the social row
	Tagline string `` /* 126-byte string literal not displayed */
	// Social is the ordered list of social footer entries rendered by modern themes
	Social []SocialLink `json:"social,omitempty" jsonschema:"-"`
	// CardStyle controls the card visual style; elevated adds rounded corners and a drop shadow
	CardStyle string `json:"cardStyle,omitempty" jsonschema:"enum=flat,enum=elevated,description=Card visual style"`
	// BodyBackgroundColor is the outer page background color
	BodyBackgroundColor string `json:"bodyBackgroundColor,omitempty" jsonschema:"description=Outer page background color"`
	// CardBackgroundColor is the card container background color
	CardBackgroundColor string `json:"cardBackgroundColor,omitempty" jsonschema:"description=Card container background color"`
	// HeroBackgroundColor is the hero banner section background color
	HeroBackgroundColor string `json:"heroBackgroundColor,omitempty" jsonschema:"description=Hero banner section background color"`
	// ButtonColor is the call-to-action button background color
	ButtonColor string `json:"buttonColor,omitempty" jsonschema:"description=Call-to-action button background color"`
	// ButtonTextColor is the call-to-action button text color
	ButtonTextColor string `json:"buttonTextColor,omitempty" jsonschema:"description=Call-to-action button text color"`
	// HeadingColor is the heading and title text color
	HeadingColor string `json:"headingColor,omitempty" jsonschema:"description=Heading and title text color"`
	// TextColor is the body paragraph text color
	TextColor string `json:"textColor,omitempty" jsonschema:"description=Body paragraph text color"`
	// FooterTextColor is the muted text color for headers, footers, and secondary content
	FooterTextColor string `json:"footerTextColor,omitempty" jsonschema:"description=Muted text color for headers footers and secondary content"`
}

UserInput is the installation-scoped configuration that customers provide when setting up their own email integration. These fields supply the branding and sender identity that the Client carries for all customer-initiated sends

func (UserInput) ToRuntimeConfig

func (u UserInput) ToRuntimeConfig() RuntimeEmailConfig

ToRuntimeConfig converts customer user input to a RuntimeEmailConfig

type VerifyBillingRequest

type VerifyBillingRequest struct {
	RecipientInfo
	// Token is the billing verification token appended to the verify URL
	Token string `json:"token" jsonschema:"required,description=Billing verification token"`
}

VerifyBillingRequest is the input for the billing email verification operation

type VerifyEmailRequest

type VerifyEmailRequest struct {
	RecipientInfo
	// Token is the email verification token appended to the verify URL
	Token string `json:"token" jsonschema:"required,description=Email verification token"`
}

VerifyEmailRequest is the input for the email verification operation

type WelcomeRequest

type WelcomeRequest struct {
	RecipientInfo
}

WelcomeRequest is the input for the welcome email operation

Directories

Path Synopsis
Package themes provides embedded email layout themes for the email integration
Package themes provides embedded email layout themes for the email integration

Jump to

Keyboard shortcuts

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