Skip to content

Latest commit

 

History

History
70 lines (54 loc) · 2.11 KB

USE_CASES.md

File metadata and controls

70 lines (54 loc) · 2.11 KB

This documentation provides examples for specific email use cases. Please open an issue or make a pull request for any email use cases you would like us to document here. Thank you!

Table of Contents

Send a Single Email to a Single Recipient

const paubox = require('paubox-nodejs');
paubox.setApiKey(process.env.PAUBOX_API_KEY);
const msg = {
  to: '[email protected]',
  from: '[email protected]',
  subject: 'Hello world',
  text: 'Hello plain world!',
  html: '<p>Hello HTML world!</p>',
};
paubox.send(msg);

BCC and Reply To

You can specify the bcc and replyTo fields for more control over who you send the email to and where people will reply to:

const msg = {
  to: '[email protected]',
  bcc: ['[email protected]', '[email protected]'],
  from: '[email protected]',
  replyTo: '[email protected]',
  subject: 'Hello world',
  text: 'Hello plain world!',
  html: '<p>Hello HTML world!</p>',
};

Advanced Usage

All other advanced settings are supported and can be passed in through the msg object according to the expected format as per the API v1 documentation.

Managing multiple API keys

In cases where you need to manage multiple instances of the mailer (or underlying client), for example when you are using multiple API keys, you can import the mail service class and instantiate new instances as required:

const {MailService} = require('paubox-nodejs');

//Instantiate mailers
const paubox1 = new MailService();
const paubox2 = new MailService();

//Set different API keys
paubox1.setApiKey('KEY1');
paubox12.setApiKey('KEY2');

// Now send emails with the mailers as needed

Kitchen Sink - an example with all settings used