Saturday, October 1, 2016

How to Send SMS Messages from Your VPS using TextBelt

Have you been looking for a way to send SMS messages from your virtual private server (VPS)? With the help of the TextBelt app, you can do just that.

TextBelt is a project created by Ian Webster that is available through open source on GitHub. It uses a REST API that sends outgoing SMS messages from your VPS. TextBelt is available as a free service.

This tutorial will show you how to setup your VPS to send SMS messages using the TextBelt SMS service.


Why TextBelt?

We chose TextBelt because it uses carrier-specific gateways to deliver your text messages for free. TextBelt claims that its service has sent over 1 million texts since being released to the public.

Some carriers are picky about which messages they deliver. A “success” response from TextBelt means that your message was delivered to the carrier. In our tests, we successfully received SMS messages that were sent to a device on the AT&T network in the United States.

Limitations of TextBelt

When we tested an international mobile device that was part of the Verizon network, we were given a success code but the SMS message was never received by the mobile user. Keep in mind that when you use TextBelt, your individual results may vary because not all carriers handle SMS messages the same.

Using the TextBelt service, the IP address of your VPS will be restricted to sending out a maximum 75 text messages per day.

This feature is in place to reduce spam. TextBelt also limits the amount of SMS messages that you can send to a specific number. The current rate is 3 texts every 3 minutes.

Some carriers may deliver text messages from txt@textbelt.com while others will simply show “Root” as the SMS sender.


How to Use TextBelt on your VPS

In order to use this service we will need to log in into our Linux VPS. For this tutorial, we will be using Ubuntu 16.04.

In order to log into your VPS from your workstation use the following command assuming X.X.X.X is the public IP of your VPS:

> ssh root@X.X.X.X

Once you connected to the server you will need to install “curl” using the two following commands:

> sudo apt-get update

> sudo apt-get install curl

Curl is used to transfer data between servers. Once curl is installed, we can begin sending text messages from the command line of your VPS.


Sending Your First Text Message from the Command Line

Now that curl is installed, we can test the TextBelt service using the following command:

> curl -X POST http://textbelt.com/text -d number=XXXXXXXXXX -d “message=I sent this message for free with textbelt.com”

Substitute the XXXXXXXXXX with the destination number.

Hereafter an example of the possible responses you will receive:

Sample success:

{“success”:true}

Please note that “Success” means that the message was sent to TextBelt’s list of providers. TextBelt cannot guarantee the delivery of the SMS. The success code simply confirms that the message was handed off to the carrier by TextBelt.

Sample failure:

{“success”:false,”message”:”Exceeded quota for this phone number.”}

Supported Carriers (USA & International)

According to TextBelt, the service is designed to work in the USA as long as the mobile device you are texting is a part of the following networks:

Alltel, Ameritech, AT&T Wireless, Boost, CellularOne, Cingular, Edge Wireless, Sprint PCS, Telus Mobility, T-Mobile, Metro PCS, Nextel, O2, Orange, Qwest, Rogers Wireless, US Cellular, Verizon, Virgin Mobile

A full list of INTL carriers including carriers in Canada is available at textbelt.com.

In order to send messages to mobile devices in CANADA, use the following command:

> curl -X POST http://textbelt.com/canada -d number=XXXXXXXXXX -d “message=I sent this message for free with textbelt.com”

If you wish to send SMS to International numbers, use the following command:

> curl -X POST http://textbelt.com/intl -d number=XXXXXXXXXX -d “message=I sent this message for free with textbelt.com”


Installing the Self Hosted Version of TextBelt on a VPS

Now that you know how to use TextBelt, here is a step by step guide on how to install the self-hosted version of the app onto your VPS.

In order to perform the installation, we will need to install a few prerequisites using the following commands:

> apt-get install npm install

> apt-get install redis-server

> apt-get install mutt

> apt-get install nodejs

Now that we have all the basic components installed, we will need to execute the redis server using the following command:

> /etc/init.d/redis-server start

You can check that the server is up and running using the following command:

> ps augx | grep redis

We will now need to download the TextBelt server and run it. First download the source code with the following command:

> mkdir /etc/textbelt/

> cd /etc/textbelt/

> wget https://github.com/typpo/textbelt/archive/master.zip

Now unzip it and execute the server:

> unzip master.zip

> cd textbelt-master

> touch server/torlist

> nodejs server/app.js &

By default, the server listens on port 9090 and it comes preconfigured to accept traffic from a reverse proxy or load balancer such as nginx. As a result, you can easily use TextBelt on your server by directing your SMS request directly to the 9090 port.

Finalize the Installation of TextBelt on your VPS

Before you can begin using this server, there are two final steps.

First we will have to open the firewall using the following command:

> iptables –I INPUT –p tcp –dport 9090 –j ACCEPT

The next step is optional, but is useful if you want your server to restart automatically when your VPS is rebooted. Execute the two following commands:

> cat “/etc/init.d/redis-server start >> /etc/rc.local

> cat “nodejs /etc/textbelt/textbelt-master/app.js &” >> /etc/rc.local

> cat “iptables –I INPUT –p tcp –dport 9090 –j ACCEPT” >> /etc/rc.local

We are now ready to send our text messages from our private server. Use the following command substituting Z.Z.Z.Z with the IP of your VPS and XXXXXXXXX with the phone number you want to text:

> curl -X POST http://Z.Z.Z.Z:9090/text -d number=XXXXXXXXXX -d “message=I sent this message for free with my VPS”

Also in this case in order to send messages in CANADA use the following command:

> curl -X POST http://Z.Z.Z.Z:9090/canada -d number=XXXXXXXXXX -d ” message=I sent this message for free with my VPS”

If you are willing to send to International numbers, use the following command:

> curl -X POST http://Z.Z.Z.Z:9090/intl -d number=XXXXXXXXXX -d ” message=I sent this message for free with my VPS”

If you begin tinkering with the TextBelt project on your VPS, let us know about your experience in the comments section below.

1 comment:

  1. If you want to get exceptional results from your bulk SMS campaign then it is very important to pick the right tools and carefully create your database of potential customers’ contact numbers. Well, I am using text messaging service for business and the results with this are absolutely great.

    ReplyDelete