Ir al contenido

Email

import { Aside } from ‘@astrojs/starlight/components’;

Email saliente desde tu artifact. Accedé vía sdk.email. El correo se envía del lado del servidor desde una dirección verificada de ShareOut; los visitantes solo pueden escribirle al dueño del artifact — nunca a destinatarios arbitrarios.

status(): Promise<EmailStatus> // is email configured?
notifyOwner(params): Promise<EmailSendResult> // send to the owner
interface EmailNotifyOwnerParams {
subject?: string;
text?: string; // required if no html
html?: string; // required if no text
replyTo?: string; // visitor's address, for the owner's reply
includeArtifactLink?: boolean; // default true
}
const { enabled, ownerEmailConfigured } = await sdk.email.status();
if (!enabled || !ownerEmailConfigured) {
// Fall back to sdk.table() to capture leads
}
await sdk.email.notifyOwner({
subject: `Contact from ${name}`,
text: `${message}\n\nFrom: ${name} <${email}>`,
replyTo: email,
});

Para envíos por cron o múltiples destinatarios, usá un job en su lugar (action: "email") — mirá Create a job.

Templates reutilizables con interpolación de variables vía sdk.templates (create / list / preview / update / delete). Usá mustache {{data.*}} y built-ins como {{artifact.name}}, {{date}}:

const tpl = await sdk.templates.create({
name: 'Weekly Report',
subject: '{{artifact.name}} — {{date}}',
html: '<h1>{{artifact.name}}</h1><p>{{data.summary}}</p>',
variables: [{ name: 'summary', type: 'string', required: true }],
});
const rendered = await sdk.templates.preview(tpl.id, { summary: 'Up 15%' });

Referenciá un template desde un job programado con template_id + template_data.