Skip to main content

EmailResource

The email resource provides methods for sending transactional emails with support for HTML, plain text, and React components.

send()

await contiguity.email.send(params: EmailSendParams): Promise<{ email_id: string }>
Send an email message.
params
EmailSendParams
required
email_id
string
Unique identifier for the sent email.

Examples

Send HTML email

const result = await contiguity.email.send({
  to: '[email protected]',
  from: '[email protected]',
  subject: 'Welcome to our service',
  html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
  text: 'Welcome! Thanks for signing up.'
});

console.log(result.email_id); // "email_..."

Send to multiple recipients

await contiguity.email.send({
  to: ['[email protected]', '[email protected]'],
  from: '[email protected]',
  subject: 'Team Update',
  html: '<p>Here is your team update.</p>',
  cc: '[email protected]',
  bcc: ['[email protected]']
});

Send with React component

import { Contiguity } from 'contiguity';
import React from 'react';

const EmailTemplate = ({ name }: { name: string }) => (
  <div>
    <h1>Hello, {name}!</h1>
    <p>Thanks for joining our service.</p>
  </div>
);

await contiguity.email.send({
  to: '[email protected]',
  from: '[email protected]',
  subject: 'Welcome!',
  react: <EmailTemplate name="John" />
});

Send with custom headers and reply-to

await contiguity.email.send({
  to: '[email protected]',
  from: '[email protected]',
  subject: 'Support Request Received',
  html: '<p>We received your request and will respond shortly.</p>',
  reply_to: '[email protected]',
  headers: {
    'X-Priority': '1',
    'X-Category': 'support'
  }
});

Notes

  • At least one of html, text, or react must be provided
  • When using react, the SDK automatically renders both HTML and plain text versions
  • The sender domain must be verified in your Contiguity account
  • Maximum 10 recipients per email (combined across to, cc, and bcc)

Build docs developers (and LLMs) love