Mail relay: docs, agent guide, skills, changelog draft; test against the real service code; starter offers the mail service

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 20:53:38 +01:00
co-authored by Claude Fable 5.2
parent 533f571d4d
commit dd3792cbc7
25 changed files with 991 additions and 167 deletions
+8 -1
View File
@@ -27,6 +27,7 @@ type GraphIntegrations = {
smtpFromName?: null | string
}
/** @deprecated Microsoft Graph as an e-mail transport is deprecated since 1.17.0 and removed in 2.0 (docs/email.md, "Moving off Microsoft Graph"). */
export type GraphAdapterArgs = {
/** Waits before the sent copy of a large-attachment message is deleted from the mailbox (ms). Default 2 s, 5 s, 15 s, 60 s. */
cleanupDelaysMs?: number[]
@@ -91,7 +92,10 @@ function readGraphEnv(): GraphEnv | null {
*/
const tokenCache = new Map<string, { expiresAt: number; token: string }>()
/** Forgets cached Graph tokens (after rotating the client secret in a running process; tests). */
/**
* Forgets cached Graph tokens (after rotating the client secret in a running process; tests).
* @deprecated With the Graph transport: removed in 2.0.
*/
export const clearGraphTokenCache = (): void => tokenCache.clear()
async function getAccessToken(env: GraphEnv, fetchImpl: typeof fetch = fetch): Promise<string> {
@@ -150,6 +154,9 @@ function toRecipients(value: SendEmailOptions['to']): { emailAddress: { address:
* Azure setup (one-time, our side): App registration → Mail.Send APPLICATION
* permission → admin consent → in Exchange, grant the app "Send As" on the
* shared mailbox GRAPH_SENDER.
*
* @deprecated Since 1.17.0; removed in 2.0. A site without SMTP sends through the Intecion
* Notifications Webservice instead (docs/email.md, "Moving off Microsoft Graph").
*/
export const graphAdapter =
(args: GraphAdapterArgs = {}): PayloadEmailAdapter =>
+4 -1
View File
@@ -20,7 +20,10 @@ export type IaplEnvFeatures = {
databaseName?: { domain?: string; warn?: (message: string) => void } | boolean
/** Override the database var. Default 'DATABASE_URI'. */
databaseVar?: string
/** Microsoft Graph e-mail (graphAdapter). Adds the GRAPH_* vars. */
/**
* Microsoft Graph e-mail (graphAdapter). Adds the GRAPH_* vars.
* @deprecated The Graph transport is deprecated since 1.17.0 and removed in 2.0; e-mail needs no variable (docs/email.md).
*/
emailGraph?: boolean
/**
* Require IAPL_IP_HEADER in production — the header the rate limit trusts for
+6 -2
View File
@@ -36,7 +36,11 @@ export type StarterAnswers = {
list: string[]
/** Inbox that receives submissions (Company → E-mail). */
recipient: string
transport: 'graph' | 'smtp'
/**
* `relay`: the Intecion mail service — no setup (email.md). `smtp`: the client's own server, typed in the panel.
* `graph` (Microsoft Graph) is deprecated and no longer offered; an answers file from before 1.17.0 that names it still works.
*/
transport: 'graph' | 'relay' | 'smtp'
}
hosting: {
/** Which host the site answers on; the other one redirects. */
@@ -124,7 +128,7 @@ export function validateAnswers(input: unknown): string[] {
need(Array.isArray(a.forms?.list), 'forms.list: the forms, e.g. ["Contact form"]')
need(isText(a.forms?.recipient) && EMAIL.test(a.forms.recipient), 'forms.recipient: the inbox that receives submissions')
need(oneOf(a.forms?.transport, ['graph', 'smtp'] as const), 'forms.transport: smtp | graph')
need(oneOf(a.forms?.transport, ['graph', 'relay', 'smtp'] as const), 'forms.transport: relay | smtp')
const c = a.consent
need(Array.isArray(c?.tools) && c.tools.every((t) => oneOf(t, TOOLS)), `consent.tools: any of ${TOOLS.join(', ')} (or [])`)
+9 -2
View File
@@ -5,6 +5,13 @@
*/
import type { StarterAnswers } from './answers.js'
/** How the project's notes name the e-mail transport the answers chose. */
const MAIL_TRANSPORT = {
graph: 'Microsoft Graph (deprecated)',
relay: 'the Intecion mail service (no setup; SMTP only on the client\'s request)',
smtp: 'SMTP from Site integrations',
} as const
export type SiteContext = {
/** `YYYY-MM-DD`, the day the site is created. */
date: string
@@ -130,7 +137,7 @@ export function renderDecisions(a: StarterAnswers, ctx: SiteContext): string {
`- Languages: ${a.languages.locales.map((l) => l.code).join(', ')} (default ${a.languages.default}), every language with a URL prefix; \`/\` redirects to \`/${a.languages.default}\`.`,
`- Styling: the IAPL token standard (\`src/design/tokens.ts\` → \`pnpm tokens\`); primary ${a.styling.primary}${a.styling.secondary ? `, secondary ${a.styling.secondary}` : ''}${a.styling.accent ? `, accent ${a.styling.accent}` : ''}; ${a.styling.fontBody} (body) + ${a.styling.fontHeading} (headings); radius ${a.styling.radius}; ${a.styling.fluid === 'wide' ? 'fluid-wide' : 'fluid'}; theme ${a.styling.theme}, default ${a.styling.defaultTheme}.`,
`- Pages and content: ${a.content.pages.join('; ')}. Collections: ${a.content.collections.length ? a.content.collections.join(', ') : 'none'}.`,
`- Forms: ${a.forms.list.length ? a.forms.list.join(', ') : 'none'}; submissions to ${a.forms.recipient}; e-mail via ${a.forms.transport === 'graph' ? 'Microsoft Graph' : 'SMTP from Site integrations'}; Turnstile on.`,
`- Forms: ${a.forms.list.length ? a.forms.list.join(', ') : 'none'}; submissions to ${a.forms.recipient}; e-mail via ${MAIL_TRANSPORT[a.forms.transport]}; Turnstile on.`,
`- Analytics and consent: ${a.consent.tools.length ? a.consent.tools.join(', ') : 'no analytics tools'}; Consent Mode ${a.consent.consentMode}; banner \`settings="${a.consent.banner}"\`; consent log on; cookie scanner ${yesNo(a.consent.cookieScanner)}${a.consent.cookieScanner ? `, crawl ${yesNo(a.consent.crawl)}` : ` — ${a.consent.cookieScannerOffReason}`}.`,
`- SEO/GEO: market ${a.market}; ${a.seo.localBusiness ? `local business (${a.seo.localBusiness.type} JSON-LD from the Company global)` : 'no local business'}; llms.txt, llms-full.txt, Markdown and MCP on; AI bots ${a.seo.aiBots}${a.seo.aiBots === 'allow' ? '' : ` — ${a.seo.aiBotsReason}`}.`,
`- Database and media: MongoDB only; database names from \`databaseNamesFor('${ctx.domain}')\` → \`${ctx.dbNames.dev}\` / \`${ctx.dbNames.prod}\`; media ${a.media === 'r2' ? 'on Cloudflare R2 in production (R2_PUBLIC_URL empty = served by the app), local disk in dev' : 'on local disk — a Coolify persistent volume in production'}.`,
@@ -170,7 +177,7 @@ export function renderAgentsMd(reference: string, a: StarterAnswers, ctx: SiteCo
const header = `# AGENTS.md
**Project:** ${a.siteName} · ${ctx.domain} · market ${a.market} · industry ${a.industry}
**Languages:** ${a.languages.locales.map((l) => (l.code === a.languages.default ? `${l.code} (default)` : l.code)).join(', ')} · **Media:** ${a.media === 'r2' ? 'R2' : 'local disk (Coolify volume)'} · **Email:** ${a.forms.transport === 'graph' ? 'Microsoft Graph' : 'SMTP from Site integrations'}
**Languages:** ${a.languages.locales.map((l) => (l.code === a.languages.default ? `${l.code} (default)` : l.code)).join(', ')} · **Media:** ${a.media === 'r2' ? 'R2' : 'local disk (Coolify volume)'} · **Email:** ${MAIL_TRANSPORT[a.forms.transport]}
`
const siteMap = `## Site map\n${a.content.pages.map((p) => `- ${p}`).join('\n')}\n\n`
+1 -1
View File
@@ -53,7 +53,7 @@ export async function askAnswers(ask: Ask): Promise<StarterAnswers> {
const collections = (await list(' Collections with their own URLs: posts, caseStudies', 'none')) as ContentCollection[]
const forms = await list('5. Forms', 'Contact form')
const recipient = await text(' Inbox that receives submissions')
const transport = await choice(' E-mail transport', ['smtp', 'graph'] as const, 'smtp')
const transport = await choice(' E-mail: relay = the built-in mail service (no setup), smtp = the client asked for its own server', ['relay', 'smtp'] as const, 'relay')
const tools = (await list('6. Analytics: ga4, gtm, metaPixel, linkedIn, tiktok, clarity', 'ga4')) as AnalyticsTool[]
const consentMode = await choice(' Consent Mode', ['advanced', 'basic'] as const, 'advanced')
const banner = await choice(' Cookie settings window', ['detailed', 'modal', 'inline'] as const, 'detailed')