messagex
v1.0.3
Published
This package enables applications to utilise all public APIs of the MessageX communications platform.
Downloads
5
Maintainers
Readme
MessageX SDK - Node
THIS SDK IS A WIP AND SHOULD NOT BE DOWNLOADED YET
This SDK provides enables node applications with an easy to use interface to the MessageX API.
Installation
npm install --save messagex
Examples
Sending email
Importing the module
var messagex = require('messagex')
The following example shows how to send an email with the bare minimum required options.
const apiKey = 'YOUR_API_KEY';
const apiSecret = 'YOUR_API_SECRET'
// Verify your credentials
messagex.authenticate(apiKey, apiSecret, function (err, response) {
const bearerToken = response.bearerToken;
// Send email
const mailSendRequest = {
from: {
address: '[email protected]',
name: 'Sender',
},
to: [
{
address: '[email protected]',
name: 'Recipient 1',
},
{
address: '[email protected]',
name: 'Recipient 2',
},
],
subject: 'Test Email Subject',
content: [
{
type: 'text/plain',
body: 'Test email body',
},
{
type: 'text/html',
body: '<html><head><title>Test HTML email body</title></head><body><p>Test HTML Email body</p></body></html>',
},
],
replyTo: {
address: '[email protected]'
},
};
messagex.sendMail(bearerToken, mailSendRequest, function(err, response){
console.log(response);
});
});