# node-smssendutil

> Dead simple zero cost SMS sending tool for node apps.

Latest version **1.0.4** (published 2018-01-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-smssendutil
pnpm add node-smssendutil
yarn add node-smssendutil
bun add node-smssendutil
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2018-01-13 |
| First published | 2018-01-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+15 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ian N. Bennett |
| Maintainers | ianisms |

## Links

- npm: https://www.npmjs.com/package/node-smssendutil
- Repository: https://github.com/ianisms/node-smssend
- Homepage: https://github.com/ianisms/node-smssend#readme
- Issues: https://github.com/ianisms/node-smssend/issues
- npm.io page: https://npm.io/package/node-smssendutil

## Dependencies (6)

- [joi](https://npm.io/package/joi.md) ^13.1.0
- [path](https://npm.io/package/path.md) ^0.12.7
- [dotenv](https://npm.io/package/dotenv.md) ^4.0.0
- [express](https://npm.io/package/express.md) ^4.16.2
- [nodemailer](https://npm.io/package/nodemailer.md) ^4.4.1
- [libphonenumber-js](https://npm.io/package/libphonenumber-js.md) ^0.4.49

## Recent versions

- 1.0.4 (latest) — 2018-01-13
- 1.0.3 — 2018-01-13
- 1.0.2 — 2018-01-13
- 1.0.1 — 2018-01-13
- 1.0.0 — 2018-01-13

## README

# node-smssend
Dead simple zero cost SMS sending tool for node apps inspired by [TextBelt](https://github.com/typpo/textbelt).  

Utilizes a map of providers to send a single SMS message to a cell phonme number via the given providers SMS via email service.
## Setup
### Installation via npm
```
npm i --save node-smssendutil
```
## Usage
You must first include and configure the SMSSend object by passing the configuration to its constructor like so:

### SMSSend Configuration Example
```
let SMSSend = require('node-smssendutil');

let providers = [
    {name: 'Alltel', emailHost: 'message.alltel.com'},
    {name: 'AT&T', emailHost: 'txt.att.net'},
    {name: 'T-Mobile', emailHost: 'tmomail.net'},
    {name: 'Virgin Mobile', emailHost: 'vmobl.com'},
    {name: 'Sprint', emailHost: 'messaging.sprintpcs.com'},
    {name: 'Verizon', emailHost: 'vtext.com'},
    {name: 'Nextel', emailHost: 'messaging.nextel.com'},
    {name: 'US Cellular', emailHost: 'mms.uscc.net'},
    {name: 'Cricket', emailHost: 'mms.cricketwireless.net'},
    {name: 'Boost', emailHost: 'myboostmobile.com'},
    {name: 'Google Fi', emailHost: 'msg.fi.google.com'},
    {name: 'Republic ', emailHost: 'text.republicwireless.com'},
];

let config = {
    providers: providers,
    emailGatewayConfig: {
        host: process.env.CONFIG_EMAILGATEWAY_HOST,
        port: process.env.CONFIG_EMAILGATEWAY_PORT,
        useTls: false,
        username: process.env.CONFIG_EMAILGATEWAY_AUTH_USERNAME,
        password: process.env.CONFIG_EMAILGATEWAY_AUTH_PASSWORD,
        mailFrom: process.env.CONFIG_EMAILGATEWAY_MAILFROM,
    },
};

let smsSend = new SMSSend(config);
```

### SMSSend Configuration
| Property | Description | Required? |
| ---------|-------------|-----------|
| providers | List of configured SMS providers with the form: ``` {name: 'AT&T', emailHost: 'txt.att.net'} ```.  If not provided the default list will be used. |  false |
| emailGatewayConfig | Holds the config for the smtp server you will use. | true |
| emailGatewayConfig.host | The host name for the smtp server. | true |
| emailGatewayConfig.port | The port for the smtp server. | true |
| emailGatewayConfig.useTls | Does your smtp server use tls? | true |
| emailGatewayConfig.username | The username for smtp server login. | true |
| emailGatewayConfig.password | The password for smtp server login. | true |
| emailGatewayConfig.mailFrom | The email adress used for outgoing mail. | true |

With the SMSSend configured, you can send an SMS message via the sendSMS method like so:
```
smsSend.sendSMS(
    'AT&T',
    process.env.TEST_SMS_NUMBER,
    'Testing SMSSend').then((result) => {
        console.log(`SUCCESS: ${result}`);
    }, (err) => {
        console.log(`FAIL: ${err.message}`);
});
```

### SMSSend.sendSMS Parameters
| Parameter | Description | Required? |
| ----------|-------------|-----------|
| providerName | The key for the provider to use in the providers list. | true |
| cellPhone | The cell phone number to send the SMS message to. | true |
| msg | The text for the SMS message to send | true |

A full example is as follows:

### Full Example
```
let dotenv = require('dotenv');
let SMSSend = require('node-smssendutil');

dotenv.config();

let providers = [
    {name: 'Alltel', emailHost: 'message.alltel.com'},
    {name: 'AT&T', emailHost: 'txt.att.net'},
    {name: 'T-Mobile', emailHost: 'tmomail.net'},
    {name: 'Virgin Mobile', emailHost: 'vmobl.com'},
    {name: 'Sprint', emailHost: 'messaging.sprintpcs.com'},
    {name: 'Verizon', emailHost: 'vtext.com'},
    {name: 'Nextel', emailHost: 'messaging.nextel.com'},
    {name: 'US Cellular', emailHost: 'mms.uscc.net'},
    {name: 'Cricket', emailHost: 'mms.cricketwireless.net'},
    {name: 'Boost', emailHost: 'myboostmobile.com'},
    {name: 'Google Fi', emailHost: 'msg.fi.google.com'},
    {name: 'Republic ', emailHost: 'text.republicwireless.com'},
];

let config = {
    providers: providers,
    emailGatewayConfig: {
        host: process.env.CONFIG_EMAILGATEWAY_HOST,
        port: process.env.CONFIG_EMAILGATEWAY_PORT,
        useTls: false,
        username: process.env.CONFIG_EMAILGATEWAY_AUTH_USERNAME,
        password: process.env.CONFIG_EMAILGATEWAY_AUTH_PASSWORD,
        mailFrom: process.env.CONFIG_EMAILGATEWAY_MAILFROM,
    },
};

let smsSend = new SMSSend(config);

smsSend.sendSMS(
    'AT&T',
    process.env.TEST_SMS_NUMBER,
    'Testing SMSGateway').then((result) => {
        console.log(`SUCCESS: ${result}`);
    }, (err) => {
        console.log(`FAIL: ${err.message}`);
});
```

### Default Providers List
You can see the default providers list [here](https://github.com/ianisms/node-smssend/blob/master/defaultProviders.js).

---
_Source: https://npm.io/package/node-smssendutil · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
