Skip to main content

Azure Functions Email Microservice & Dispatch Engine

All transactional notifications, quote confirmations, agent lead alerts, password recovery links, and privacy disclosures in veridex-hitech-web-application are orchestrated through a unified email delivery subsystem (src/lib/email.ts).


1. Dual-Architecture Dispatch​

To guarantee deliverability across varied environments (cloud production, local development, and CI/CD pipelines), the application supports dual dispatch mechanisms:

1.1 Primary Method: Azure Functions Microservice​

  • Transport: HTTPS POST to the dedicated Azure Email Function microservice.
  • Authentication: Injects x-functions-key: process.env.EMAIL_SERVICE_AUTH_KEY into request headers.
  • Timeout & Retry Policy: Configured with a 10-second request timeout. If Azure returns a 5xx error or socket timeout (common during serverless cold starts), the dispatcher automatically pauses for 1,000ms and executes one retry attempt before throwing an error.

1.2 Development Mode Safe Routing (NEXT_PUBLIC_EMAIL_TO)​

In non-production environments (preview branches, staging, local dev), sending test emails to real customer email addresses is prevented by configuring NEXT_PUBLIC_EMAIL_TO:

  • When set, all outgoing transactional emails are dynamically diverted to the specified internal testing inbox.
  • The original intended recipient is appended to the subject line: [DEV to: customer@example.com] Your HiTech Quote Confirmation.

2. Team Notification Routing Matrix​

Different inquiries route to specialized underwriting and operational departments within the agency:

Inquiry TypeOriginating RoutePrimary Destination InboxCC Routing
Get a Quote (General Lines)/get-quote, homepagequotes@hightechinsurance.com-
Get a Quote (Commercial Truck)/insurance/truck-insuranceTrucking@hightechinsurance.com-
Schedule a Call/schedule-a-callquotes@hightechinsurance.com-
First Notice of Loss Claim/file-a-claimclaims@hightechinsurance.com-
Career Application/careersApply@hightechinsurance.com-
Contact Inquiries/contactcontactus@hightechinsurance.com-
Newsletter SubscriptionFooter formnewsletter@hightechinsurance.com-
Privacy Data Request/privacy-request-intakeprivacy@hightechinsurance.comdatasecurity@prismonesvcs.com
Privacy Decision Appeal/privacy-appealprivacy@hightechinsurance.comdatasecurity@prismonesvcs.com

3. Email Templates Library (src/lib/emails/)​

Transactional emails are compiled using responsive HTML tables with inline styles to ensure 100% rendering fidelity across strict desktop and mobile clients (Microsoft Outlook, Apple Mail, Gmail, Yahoo):

  • WelcomeEmail (welcome-email.ts): Sent upon customer account creation with account credentials overview.
  • VerificationEmail (verification-email.ts): Contains single-use security token for email address confirmation.
  • PasswordResetEmail (password-reset-email.ts): Dispatches a time-limited password recovery link.
  • QuoteReceiptEmail (quote-receipt-email.ts): Delivers a detailed breakdown of coverage parameters to the policyholder.
  • AgentLeadAlertEmail (agent-lead-alert-email.ts): Immediate alert sent to licensed agency staff with full lead contact data for rapid callback.
  • PrivacyIntakeEmail (privacy-intake-email.ts): Formal regulatory receipt detailing statutory compliance timelines (45 days under CCPA/TDPSA).

4. Visual Email Testing Interface (/email-preview)​

Developers and QA engineers can preview and inspect rendered HTML email templates in real time:

  • Accessible at http://localhost:3000/email-preview.
  • Allows toggling between different template variants (Quote, Claim, Welcome, Reset).
  • Renders responsive iframe previews simulating desktop and mobile viewports.