email

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package email provides the orchestration layer for outbound transactional email. It wraps a pkg/email.EmailProvider (SES or Noop) and centralizes message construction so that email bodies and link shapes are defined in one place rather than scattered as inline fmt.Sprintf calls across handlers.

The Service holds a resolved provider + baseURL. Handlers depend on the concrete *Service (the provider is the injectable seam, already an interface). baseURL is retained for the password-reset / email-verification flows (US-49.5/49.6) which build interstitial frontend links.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConfigured = errors.New("email is not configured")

ErrNotConfigured is returned when the Service has no provider (email is disabled). Callers use ProviderName() to distinguish noop from ses for UX; this sentinel guards against calling Send* on a nil-provider Service.

Functions

This section is empty.

Types

type Service

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

Service builds and sends transactional emails via the wrapped provider.

func NewService

func NewService(provider email.EmailProvider, baseURL, providerName string) *Service

NewService constructs a Service. provider may be nil (email disabled); in that case Send* returns ErrNotConfigured. baseURL is the public origin used to build links in email bodies (consumed by US-49.5/49.6). providerName is the resolved provider label for UX ("ses", "noop"); empty or unknown values normalise to "noop".

func (*Service) ProviderName

func (s *Service) ProviderName() string

ProviderName returns the resolved provider label for UX ("ses" or "noop").

func (*Service) SendEmailVerification

func (s *Service) SendEmailVerification(ctx context.Context, to, token string) error

SendEmailVerification sends an email-verification link. The link targets the interstitial frontend page /verify-email, which POSTs to the verify endpoint — never a consuming GET (scanner-defense invariant, US-49.9).

func (*Service) SendPasswordChanged

func (s *Service) SendPasswordChanged(ctx context.Context, to string) error

SendPasswordChanged sends a post-reset notification so the legitimate owner can detect an account takeover. Per OWASP, this is a notification, not a gate — it does not block the reset.

func (*Service) SendPasswordReset

func (s *Service) SendPasswordReset(ctx context.Context, to, token string) error

SendPasswordReset sends a password-reset link. The link targets the interstitial frontend page /reset-password, which POSTs to the confirm endpoint — never a consuming GET (scanner-defense invariant, US-49.9).

func (*Service) SendTest

func (s *Service) SendTest(ctx context.Context, to string) error

SendTest sends a test email so an admin can verify SES wiring end-to-end.

Jump to

Keyboard shortcuts

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