messagebus

5.0.0 • Public • Published

MB icon

Message Bus Node.js sdk

Message Bus is a cloud-based platform for easily sending email at scale and with complete insight into your messaging traffic and how recipients are responding to it. All platform functions are available via REST API as well as the language-specific documentation, sample code, libraries, and/or compiled binaries contained in this SDK.

Samples include how to:

  • Create sessions
  • Send messages
  • Use templates
  • Use webhooks

If you have questions not answered by the samples or the online documentation, please contact support.

Installing the module

npm install messagebus

Sending emails

var client = new MessageBusAPIClient('apiKey');
var sessionKey = "DEFAULT";

var messages = [{
        toEmail: "bob@example.com",
        toName: "Bob",
        subject: "Sample Message with HTML body.",
        plaintextBody: "This is the plain text body.",
        htmlBody: "This is the <b>HTML</b>body.",
        fromEmail: "alice@example.com",
        fromName: "Alice W.",
        returnPath: "bounces@examples.com",
        sessionKey: sessionKey
    }, {
        toEmail: "john@example.com",
        toName: "John",
        subject: "Simple Example with no HTML body.",
        plaintextBody: "This is a plaintext example.",
        fromEmail: "alice@example.com",
        fromName: "Alice W.",
        returnPath: "bounces@examples.com",
        sessionKey: sessionKey
    }
];

client.sendMessages(messages, function(err, resp) {
    if (err) console.error("Error: %j", err);
    else {
        console.info("Email send results");
        for (var i = 0; i < resp.results.length; i++) {
            console.info("To: %s, Message Id: %s, Message Status: %s",
                resp.results[i].toEmail, resp.results[i].messageId, resp.results[i].messageStatus);
        }
    }
});

License

Copyright (c) 2014 Mail Bypass, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License

Package Sidebar

Install

npm i messagebus

Weekly Downloads

1

Version

5.0.0

License

none

Last publish

Collaborators

  • thesmart
  • messagebus