0.0.1 • Published 4 years ago

@tshio/mailer-client v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

RAD Mailer Client

npm version

Non-blocking RAD Mailer client for Node.js.

This is a 100% JavaScript library, with TypeScript definition, with the Promise API.

This module makes it simple to implement a Node.js application that uses RAD Mailer.

Table of Contents

Installing

$ npm install @tshio/mailer-client

or

$ yarn add @tshio/mailer-client

Loading and configuration module

// CommonJS
const { MailerClient } = require('@tshio/mailer-client');

// ES Module
import { MailerClient } from '@tshio/mailer-client';


const options = {
  host: "localhost",
  port: "50060",
}

const mailerClient = new MailerClient(options);

Getting started

Send email

const request: SendRequest = {
emails: [
  {
    sender: {
      name: "tsh.io",
      email: "sender@example.com",
    },
    recipient: {
      to: ["recipient@example.com"],
    },
    template: {
      id: "test",
      parameters: {
        firstName: "Antonio",
        lastName: "Hernández",
      },
    },
  },
],
}

await mailerClient.mailer.send(request);

API

mailerClient.mailer.send({ emails, priority }) => Promise< void >

Send emails

Returns void or throw HttpError

Parameters
NameTypeDescriptionDefault
messagesobject[]Array of MailMessage
prioritystringoptional Send priority, allowed values: urgent, high, medium, lowurgent
Mail message
NameTypeDescriptionDefault
senderobjectSender object
sender.namestringSender name
sender.emailstringSender email
recipientobjectRecipient object
recipient.tostring[]Recipient to
recipient.ccstringoptional Recipient bcc
recipient.bccstringoptional Recipient bcc
templateobjectTemplate object
template.idstringTemplate id
template.parametersobjectTemplate parameters
attachmentsobject[]Attachments objects array
attachment.fileNamestringAttachments file name
attachment.contentstringAttachments content encoded with base64

License

license

This project is licensed under the terms of the MIT license.

About us:

The Software House