This is a Parse.com Cloud Code Module for the Sendwithus API based on the official Sendwithus NodeJS Client, check there for the most up to date usage documentation.
Copy sendwithus.js
to your Parse Cloud Code cloud
directory
All callbacks accept err
and data
:
var callback = function(err, data) {
if (err) {
console.log(err.message, err.status);
} else {
console.log(data);
}
};
var api = require('cloud/sendwithus.js')(API_KEY);
api.emails(callback);
The email_data
field is optional, but highly recommended!
ar api = require('cloud/sendwithus.js')(API_KEY);
api.send({
email_id: EMAIL_ID,
recipient: { address: '[email protected]'}
}, callback);
ar api = require('cloud/sendwithus.js')(API_KEY);
api.send({
email_id: EMAIL_ID,
recipient: {
address: '[email protected]', // required
name: 'Matt and Brad'
},
email_data: { first_name: 'Matt' }
}, callback);
sender['address']
is a required sender field
var api = require('cloud/sendwithus.js')(API_KEY);
api.send({
email_id: EMAIL_ID,
recipient: { address: '[email protected]'},
email_data: { first_name: 'Matt' },
sender: {
address: '[email protected]', // required
name: 'Company'
}
}, callback);
sender['name']
and sender['reply_to']
are both optional
var api = require('cloud/sendwithus.js')(API_KEY);
api.send({
email_id: EMAIL_ID,
recipient: { address: '[email protected]'},
email_data: { first_name: 'Matt' },
sender: {
address: '[email protected]', // required
name: 'Company',
reply_to: '[email protected]'
}
}, callback);
var api = require('sendwithus')(API_KEY);
api.send({
email_id: EMAIL_ID,
recipient: { address: '[email protected]'},
bcc: [{ address: '[email protected]' }],
cc: [
{ address: '[email protected]' },
{ address: '[email protected]' }
]
}, callback);
> err.status;
400
> err.status;
403