sendwithus

SendWithUs.com Node.js client

npm install sendwithus
18 downloads in the last day
195 downloads in the last week
741 downloads in the last month

sendwithus node-client

Installation

npm install sendwithus

Usage

All callbacks are accept err and data:

var callback = function(err, data) {
    if (err) {
        console.log(err, err.statusCode);
    } else {
        console.log(data);
    }
};

List Your Emails

var api = require('sendwithus')(API_KEY);
api.emails(callback);

Send an Email

Call with REQUIRED parameters only

The email_data field is optional, but highly recommended!

var api = require('sendwithus')(API_KEY);
api.send({
    email_id: EMAIL_ID,
    recipient: { address: 'us@sendwithus.com'}
}, callback);

Call with REQUIRED parameters and email_data

var api = require('sendwithus')(API_KEY);
api.send({
    email_id: EMAIL_ID,
    recipient: {
        address: 'us@sendwithus.com', // required
        name: 'Matt and Brad' 
    },
    email_data: { first_name: 'Matt' } 
}, callback);

Optional Sender

sender['address'] is a required sender field

var api = require('sendwithus')(API_KEY);
api.send({
    email_id: EMAIL_ID,
    recipient: { address: 'us@sendwithus.com'},
    email_data: { first_name: 'Matt' },
    sender: {
        address: 'company@company.com', // required
        name: 'Company' 
    }
}, callback);

Optional Sender with reply_to address

sender['name'] and sender['reply_to'] are both optional

var api = require('sendwithus')(API_KEY);
api.send({
    email_id: EMAIL_ID,
    recipient: { address: 'us@sendwithus.com'},
    email_data: { first_name: 'Matt' },
    sender: {
        address: 'company@company.com', // required
        name: 'Company',
        reply_to: 'info@company.com'
    }
}, callback);

expected response

Error cases

malformed request

    > err.statusCode;
    400

bad api key

    > err.statusCode;    
    403

Run Tests

npm test
npm loves you