OpenSES

Emails

Send, retrieve, list, and cancel transactional emails.

Send

const result = await client.emails.send({
  from: 'Acme <noreply@acme.com>',
  to: ['ada@example.com', 'grace@example.com'],
  cc: 'team@example.com',
  bcc: 'audit@example.com',
  replyTo: 'support@example.com',
  headers: {
    'X-Entity-ID': 'user_123',
  },
  attachments: [
    {
      path: './invoice.pdf',
      filename: 'invoice.pdf',
    },
  ],
  subject: 'Welcome to Acme',
  html: '<h1>Welcome</h1>',
  text: 'Welcome',
  tags: {
    source: 'signup',
  },
});

The response contains an email ID and status: 'queued'.

replyTo accepts one address or an array. Attachments accept base64 content, Uint8Array/Buffer content, a local path, or an HTTP(S) URL. The total attachment size is limited to 40 MB.

Use an idempotency key to make retries return the original queued email:

await client.emails.send(
  {
    from: 'Acme <noreply@acme.com>',
    to: 'user@example.com',
    subject: 'Welcome',
    text: 'Welcome',
  },
  {
    idempotencyKey: 'welcome-user-123',
  },
);

Templates

await client.emails.send({
  from: 'Acme <noreply@acme.com>',
  to: 'user@example.com',
  subject: 'Welcome',
  template: 'welcome',
  variables: {
    name: 'Ada',
    accountId: 1042,
  },
});

Get

const email = await client.emails.get('em_123');

console.log(email.status);
console.log(email.events);

The event list is chronological and can include delivery, bounce, complaint, open, click, delay, failure, and suppression events.

List

const page = await client.emails.list({
  status: 'delivered',
  from: '2026-06-01T00:00:00.000Z',
  to: '2026-06-30T23:59:59.999Z',
  search: 'example.com',
  pageSize: 50,
});

for (const email of page.data) {
  console.log(email.id, email.subject);
}

if (page.nextCursor) {
  const nextPage = await client.emails.list({
    cursor: page.nextCursor,
    pageSize: 50,
  });
}

Cancel

await client.emails.cancel('em_123');

Only queued emails can be cancelled. OpenSES throws ConflictError once processing has advanced beyond the queued state.