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 ¶
- Variables
- type Service
- func (s *Service) ProviderName() string
- func (s *Service) SendEmailVerification(ctx context.Context, to, token string) error
- func (s *Service) SendPasswordChanged(ctx context.Context, to string) error
- func (s *Service) SendPasswordReset(ctx context.Context, to, token string) error
- func (s *Service) SendTest(ctx context.Context, to string) error
Constants ¶
This section is empty.
Variables ¶
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 ¶
ProviderName returns the resolved provider label for UX ("ses" or "noop").
func (*Service) SendEmailVerification ¶
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 ¶
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 ¶
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).