@axene/mailer
v0.1.1
Published
Official TypeScript/JavaScript SDK for Axene Mailer: send receipts, confirmations, and campaigns from your own domain. Priced in KES, billed via M-Pesa.
Maintainers
Readme
@axene/mailer
Official TypeScript / JavaScript SDK for Axene Mailer. Send receipts, confirmations, and campaigns from your own domain, priced in KES, billed via M-Pesa.
Zero runtime dependencies. Works in Node 18+, Bun, Deno, and edge runtimes (anywhere fetch exists).
Install
npm install @axene/mailerUsage
import { Axene } from '@axene/mailer';
const axene = new Axene({ apiKey: process.env.AXENE_API_KEY! });
const { id } = await axene.emails.send({
from: { email: '[email protected]', name: 'Your Shop' },
to: '[email protected]',
subject: 'Your receipt',
html: '<p>Thanks for your order.</p>',
text: 'Thanks for your order.',
});
console.log('queued', id);Recipients
to, cc, bcc accept a string, an object, or arrays of either:
to: '[email protected]'
to: { email: '[email protected]', name: 'Ada' }
to: ['[email protected]', { email: '[email protected]', name: 'Bee' }]More
await axene.emails.sendBatch([ /* up to your plan's batch limit */ ]);
const email = await axene.emails.get(id); // status
const events = await axene.emails.events(id); // delivered / opened / clicked / bounced
await axene.emails.validate('[email protected]'); // address check
await axene.domains.list(); // your sending domains
// Scheduling (Starter plan and up)
await axene.emails.send({ from, to, subject, html, sendAt: new Date(Date.now() + 3600_000) });Errors & retries
Non-2xx responses throw AxeneError (.status, .code, .message). The client
automatically retries 429 and 5xx with exponential backoff (configurable via
maxRetries).
import { Axene, AxeneError } from '@axene/mailer';
try {
await axene.emails.send({ /* … */ });
} catch (e) {
if (e instanceof AxeneError) console.error(e.status, e.code, e.message);
}Options
new Axene({
apiKey: '…', // required, starts with axm_k_
baseUrl: 'https://mail.axene.io', // override if self-hosting
maxRetries: 3,
timeoutMs: 30000,
fetch: customFetch, // for Node < 18
});Get an API key at mail.axene.io. Docs: https://axene.io/docs/mailer/getting-started/welcome.
MIT © Axene Solutions
