node-notification

0.2.0 • Public • Published

node-notification NPM version Build Status Dependency Status Coverage percentage

Node Notification with Email, SMS.

Install

$ npm install --save node-notification

Usage

var notifier = require('node-notification');
//短信
var mailOptions = {
  from: process.env.NN_FROM,
  to: process.env.NN_TO,
  subject: 'hello world!',
  body: 'Greeting from'
};
var smtpOptions = {
  host: 'smtp.exmail.qq.com',
  port: 465,
  secure: 'true',
  password: process.env.NN_PASSWORD,
  email: process.env.NN_EMAIL
};
var sender = notifier.senders.mailer;
sender.send(smtpOptions, mailOptions, function(error, data) {
  //data:返回的json数据
});
 
//短消息    
var config = {
  url: 'sandboxapp.cloopen.com',
  port: 8883,
  version: '2013-12-26',
  appId: process.env.NN_APPID,
  accountSid: process.env.NN_ACCOUNTSID,
  accountToken: process.env.NN_ACCOUNTTOKEN
};
var data = {
  phone: process.env.NN_PHONE,
  params: [' 云通讯测试', "" + Math.round(Math.random() * 1000000) ],
  templateId: '1'
};
var sms = notifier.senders.sms;
sms.send(config, data, function(error, data) {
  assert.equal(true, !error);
  assert.equal(true, data.statusCode === '000000');
  done();
});

License

Apache-2.0 © calidion

Readme

Keywords

none

Package Sidebar

Install

npm i node-notification

Weekly Downloads

8

Version

0.2.0

License

Apache-2.0

Last publish

Collaborators

  • calidion