inmake DOCS
Docs / SDK / Mailing

Mailing

Send a store e-mail template through its own SMTP.

Mailing (DropCoreMailing)#

src/mailing/drop_core_mailing.ts. Route mailing/send. Free — not credit-metered.

Sends one of the store's Handlebars e-mail templates through the store's own SMTP setup. The template is the unit of configuration: subject, sender, reply-to, body and the email.enabled toggle all live on the template record at store/{sid}/data/{locale}/templates/{template}, so copy changes need no redeploy on the calling side. The caller supplies only the recipient and the render variables.

await core.mailing.send({
    template: 'invitation',              // record id under data/{locale}/templates
    locale: 'cs_CZ',                     // default: the store's primary locale
    to: {direct: 'jana@acme.cz'},        // or a string / string[] / {list} / {topic}
    data: {workspace: 'Acme s.r.o.', mail: 'jana@acme.cz'},
});
// → {status: 'success', count: 1, accepted: [...], rejected: [], messageId, response}

data is flattened server-side before the Handlebars pass, so {customer: {name: 'Jane'}} reaches the template as {{customer_name}}; arrays survive intact for {{#each}}.

A template whose email.enabled is explicitly false resolves with {status: 'skipped'} — a successful call that deliberately sent nothing. A store with no setup/smtp doc rejects with Client not found; client selects a different setup/{client} doc when a store has several.

references and schedule are accepted and echoed back on the result, but are not acted on server-side yet.