Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ralyodio/app-notify
Send SMS and email notifications from within your node.js app
https://github.com/ralyodio/app-notify
Last synced: about 2 months ago
JSON representation
Send SMS and email notifications from within your node.js app
- Host: GitHub
- URL: https://github.com/ralyodio/app-notify
- Owner: ralyodio
- License: isc
- Created: 2014-12-14T07:59:54.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-31T00:05:10.000Z (almost 2 years ago)
- Last Synced: 2024-10-23T11:13:04.917Z (2 months ago)
- Language: JavaScript
- Size: 502 KB
- Stars: 83
- Watchers: 5
- Forks: 22
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
app-notify
==========Send Twilio SMS and SMTP email notifications from within your node.js app
# install
```shell
npm install app-notify
``````javascript
const Notify = require('app-notify');
const cfg = {...};
const notify = new Notify(cfg);
```# usage (promises)
### Send an email message:
```javascript
const cfg = {};//setup smtp server
cfg.smtp = {
host: xxx,
user: user,
pass: pass,
port: port
};//setup email headers
cfg.email = {
to: '[email protected]',
from: '[email protected]'
};const Notify = require('app-notify');
const notify = new Notify(cfg);//send an email
notify.email.send({
subject: 'This is a test',
message: 'Hello world!'
})
.then(function(data){
console.log(data);
})
.catch(function(err){
console.error(err);
});
```### Send an SMS message
```javascript
const cfg = {};//setup sms configuration
cfg.sms = {
sid: 'twilio-sid-id',
auth: 'twilio-auth-id',
to: 'xxx-xxx-xxxx', //recipient
from: 'yyy-yyy-yyyy' //your twilio assigned phone number
};const Notify = require('app-notify');
const notify = new Notify(cfg);notify.sms.send({
message: 'Hello world'
})
.then(function(data){
console.log(data);
})
.catch(function(err){
console.error(err);
});
```### Send to whichever services we have enabled (both sms and email):
```javascript
const cfg = {};//setup smtp server
cfg.smtp = {
host: xxx,
user: user,
pass: pass,
port: port
};//setup email headers
cfg.email = {
to: '[email protected]',
from: '[email protected]'
};const Notify = require('app-notify');
const notify = new Notify(cfg);//sends both
notify.send({
subject: 'This is a test',
message: 'Hello world'
});//disable email
notify.cfg.email.disabled = true;//sends only sms
notify.send({
message: 'Hello world',
});
```# usage (callbacks)
app-notify can be used with callbacks too!
# run tests
```shell
gulp test
```