Skip to content

Getting Started ​

Getting started with @yizack/mailchannels

Overview ​

This library provides a simple way to interact with the MailChannels API. It is written in TypeScript and can be used in both JavaScript and TypeScript projects and in different runtimes.

Installation ​

Add @yizack/mailchannels dependency to your project

sh
npm i @yizack/mailchannels
sh
yarn add @yizack/mailchannels
sh
pnpm add @yizack/mailchannels

Quick Start ​

This library can be used in two ways:

  • Importing the whole library
  • Importing the client and only the modules you need

Importing the whole library ​

In this example, we import the whole library and use the MailChannels class to send an email.

ts
import { MailChannels } from '@yizack/mailchannels'

const mailchannels = new MailChannels('your-api-key')
const { success } = await mailchannels.emails.send({
  // ...
})

This method is useful when building an application on top of MailChannels and you need to use multiple modules from the library.

Importing only the modules you need ​

In this example, we import the MailChannelsClient and the Emails module to send an email.

ts
import { MailChannelsClient } from '@yizack/mailchannels'
import { Emails } from '@yizack/mailchannels/modules'

const mailchannels = new MailChannelsClient('your-api-key')
const emails = new Emails(mailchannels)
const { success } = await emails.send({
  // ...
})

This method is useful when you only need to use a specific module from the library and want to reduce the bundle size.

Released under the MIT License.