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!
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);
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>',
};
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.
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