Send transactional and templated emails
Sending an email
await nutifar.notifications.sendEmail({
to: "user@example.com",
template: {
name: "welcome",
data: { name: "Yusuf" },
},
});to is required for every send — Nutifar doesn't persist recipient records,
so there's no stored address to fall back to. Scopes the send to your app's
templates and verified sender identities.
Templates
Templates are managed from your tenant dashboard under Email → Templates. Reference a template by its name and pass variables via template.data:
await nutifar.notifications.sendEmail({
to: "user@example.com",
template: {
name: "invoice-receipt",
data: {
invoiceNumber: "INV-1029",
amount: "$49.00",
},
},
});Sending without a template
For one-off or dynamically generated content, skip template and pass subject + html (or text) directly:
await nutifar.notifications.sendEmail({
to: "user@example.com",
subject: "Your report is ready",
html: "<p>Your monthly report is attached.</p>",
});Multiple recipients, cc, bcc
to, cc, and bcc all accept a single address or an array, as either a plain string or { email, name }:
await nutifar.notifications.sendEmail({
to: [{ email: "user@example.com", name: "Jane Doe" }],
cc: "ops@example.com",
subject: "Your report is ready",
html: "<p>Your monthly report is attached.</p>",
});Custom sender
By default, emails send from your app's verified domain identity. Override per-send with from:
await nutifar.notifications.sendEmail({
to: "user@example.com",
from: { email: "billing@yourdomain.com", name: "YourApp Billing" },
subject: "Your invoice",
html: "<p>...</p>",
});If from isn't a verified sender identity for your app, Nutifar falls back to sending from Nutifar <demo@nutifar.buzz> rather than rejecting the request. Verify your sending domain from the dashboard before relying on a custom from address in production.
Attachments
Attach files by base64-encoded content (small files) or a hosted url (recommended for anything non-trivial in size):
await nutifar.notifications.sendEmail({
to: "user@example.com",
template: {
name: "invoice-receipt",
data: { invoiceNumber: "INV-1029" },
},
attachments: [
{
filename: "invoice.pdf",
content: pdfBuffer.toString("base64"),
contentType: "application/pdf",
},
],
});Delivery status
Delivery status reporting (delivered/bounced/opened/clicked) is not yet documented — confirm this section against the actual webhook/event system before publishing.
Errors
Error codes below are placeholders pending confirmation against actual API error responses — do not publish until verified.
| Error | Cause |
|---|---|
invalid_recipient | to is not a valid email address |
template_not_found | template.name doesn't exist for this app |
sender_not_verified | Custom from domain isn't verified — falls back to default sender rather than erroring |