# PETVITY · Email Templates

Drop-in HTML email templates for the core lifecycle. Compatible with **Resend** (recommended), Postmark, SendGrid, Mailgun, or any provider that accepts raw HTML.

## Templates

| File | Trigger | Subject | Variables |
|---|---|---|---|
| `01-welcome.html` | Profile completion (immediate) | `{{petName}}'s Pet-Harmony Score is ready 🐾` | `ownerFirst, petName, species, harmonyScore, topGoal` |
| `02-day-3-orient.html` | 72h after profile, if not upgraded | `A small thing for {{petName}} this week` | `ownerFirst, petName, topRecommendation` |
| `03-week-1-deep-read.html` | 7 days after profile | `One real article for {{petName}}'s healthspan` | `ownerFirst, petName, matchedArticleTitle, matchedArticleUrl` |
| `04-founder-thank-you.html` | Stripe webhook · founder subscription | `Welcome, founder. (No. {{founderNumber}})` | `ownerFirst, tier, founderNumber, remainingSpots, firstShipMonth` |
| `05-course-start.html` | Course purchase OR Plus/Premium upgrade | `You're enrolled — Module 1 starts when you do` | `ownerFirst, petName, accessType` |

## Wiring

### Resend (recommended)

```js
// In netlify/functions/welcome-email.js (already exists, swap template inline)
const html = readFileSync('./email-templates/01-welcome.html', 'utf-8')
  .replace(/\{\{ownerFirst\}\}/g, ownerFirst)
  .replace(/\{\{petName\}\}/g, petName)
  // ... etc
  ;
await fetch('https://api.resend.com/emails', { ... });
```

### Sequence orchestration

Either:
- **Resend Sequences** (built-in delays + conditions) — wire each template as a step
- **Customer.io / Loops.so** — load all 5 as transactional templates with delay rules
- **HubSpot Workflows** — if you've already set up the CRM via `lead.js`, use HubSpot's email tool

## Personalization tips

- `{{topGoal}}` and `{{topRecommendation}}` are pulled from the user's Pet Profile goals array. The simplest mapping:
  - `joints` → "joint mobility" / "Add fish oil 100mg per kg body weight, daily, with breakfast"
  - `kidney` → "kidney health" / "Switch one daily meal to wet food this week"
  - `digestion` → "digestion" / "Same feed time every day, including weekends"
  - `calm` → "stress and calm" / "30 minutes earlier dim-light evening routine"
  - `energy` → "energy and vitality" / "One additional 20-min sniff walk daily"
  - `kognitive` → "cognitive aging" / "Rotate one toy/activity each week for novelty"
- `{{matchedArticleTitle/Url}}` — use the same goal mapping to surface the most relevant deep article.

## Design notes

- Forest #1a3a2a + Gold #d4af37 + Ivory #fefdfb — same palette as the site
- All templates use system + Georgia fallbacks (Italiana isn't available in most email clients)
- Tested in Apple Mail, Gmail web, Outlook 365, iOS Mail
- Width capped at 560px — render correctly on mobile

## Unsubscribe compliance

Every template includes `{{unsubscribe_url}}` — your ESP (Resend, etc.) typically auto-injects this. Required for GDPR and CAN-SPAM.

## Rolling out

Recommended sequence to enable in order:
1. **Email 1 (Welcome)** — already wired in `netlify/functions/welcome-email.js`. Just need `RESEND_API_KEY` env var.
2. **Email 4 (Founder thank-you)** — high priority once founder Stripe is live
3. **Email 5 (Course-start)** — once Plus/Premium memberships are paying
4. **Email 2 (Day-3 orient)** — drip
5. **Email 3 (Week-1 deep read)** — drip

Don't enable all five at once. Each one is opt-in to receive — check the open rate of #1 before adding #2, etc.
