This SDK provides enables node applications with an easy to use interface to the MessageX API.
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'
messagex.authenticate(apiKey, apiSecret, function (err, response) {
const bearerToken = response.bearerToken;
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);
});
});