# Superseded placement note — v393

This early notification plan is preserved for history and for reusable shared-service concepts. Its older placement, SMTP/env, Notification Center, and provider assumptions are superseded by the current build rules, v384-v390 notification work, and the active placement rule: `/notifications` is alert/action-only; Workspace Settings > Notifications owns preferences, phone capture, and opt-ins; `/company/integrations` owns provider setup.

---

CURRENT CANONICAL BASELINE
Version: v39
Status: documentation expansion package
Next planned package: v40

# Notifications and Messaging Plan

## Current phase note
- v39.1 formalizes email delivery, SMTP integration, internal notifications, operational alerts, and future SMS support.

## Purpose
This document defines the notification and messaging architecture for Dispatch Spot so account, operational, security, and business alerts can be delivered consistently through in-app, email, and future SMS channels.

## Core Principle
Notifications must be generated by a shared notification service rather than scattered direct-send logic inside page handlers or route code.

## Initial Channel Strategy
- In-app notifications: primary workflow surface
- Email notifications: primary durable external channel
- SMS notifications: reserved for urgent and time-sensitive events after the email foundation is stable

## SMTP Integration Plan
### Initial Requirements
- SMTP transport support behind a provider adapter
- environment-based mail configuration
- sender identity separation for security, alerts, and system notices
- delivery logging and failure tracking

### Recommended Environment Variables
- SMTP_HOST
- SMTP_PORT
- SMTP_SECURE
- SMTP_USER
- SMTP_PASS
- SMTP_FROM_EMAIL
- SMTP_FROM_NAME
- SMTP_REPLY_TO
- SMTP_CONNECTION_TIMEOUT_MS
- SMTP_RATE_LIMIT_PER_MINUTE

### Deliverability Requirements
Before production email is enabled:
- publish SPF
- publish DKIM
- publish DMARC
- use a dedicated notification subdomain when possible
- monitor bounce and failure mailboxes

## Notification Service Responsibilities
- template rendering
- recipient resolution
- channel routing
- preference checks
- queueing and retry policy
- delivery status tracking
- audit logging for security-sensitive sends

## Notification Categories
### Security and Account
- email verification
- password reset
- password changed
- login challenge
- new login detected
- role changed
- invite sent and accepted

### CRM and Commercial Operations
- lead assigned
- follow-up due
- stale pipeline reminder
- activity overdue
- document requested
- onboarding incomplete

### Dispatch and Load Operations
- new load assigned
- load status changed
- pickup approaching
- delivery approaching
- missed check call
- detention risk
- proof-of-delivery missing
- dispatch exception raised

### Billing and Workspace Operations
- invoice generated
- payment failed
- trial ending
- subscription changed
- seat threshold reached

### Internal Platform Operations
- SMTP delivery failure
- failed integration alert
- queue backlog alert
- workspace pending review
- support action required

## Notification Preferences Direction
Users should eventually be able to choose among:
- immediate email
- digest email
- in-app only
- mute non-critical messages

Mandatory notifications must still exist for:
- password change
- billing failure for workspace owner
- elevated role changes
- high-risk security events

## Notification Audit and Delivery Logging
Each outbound notification should preserve the following metadata:
- notification type
- channel
- template key
- user id
- workspace id
- recipient
- created at
- sent at
- attempt count
- final status
- failure reason

## SMS Architecture Direction
SMS should be introduced through the same notification service using a second provider adapter.

### Early SMS Use Cases
- urgent dispatch exceptions
- pickup and delivery reminders
- compliance expiry reminders
- login verification codes
- missed check-call escalation

### SMS Rules
- explicit opt-in
- verified phone number
- quiet-hour support
- concise message bodies
- preference-aware delivery

## Build Rule Going Forward
All new notification work must preserve channel abstraction, auditability, and preference support.
