1.0.3 • Published 5 years ago
messagex v1.0.3
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: 'sender@messagex.com',
name: 'Sender',
},
to: [
{
address: 'recipeint1@messagex.com',
name: 'Recipient 1',
},
{
address: 'recipeint2@messagex.com',
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: 'replyto@messagex.com'
},
};
messagex.sendMail(bearerToken, mailSendRequest, function(err, response){
console.log(response);
});
});