LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

How to Send SMS Messages from Your VPS using TextBelt

lowendtutorial

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.

 

17 Comments

  1. Marcus:

    Cool!

    September 8, 2016 @ 7:32 pm | Reply
  2. Jon:

    I tried it with a roger’s phone in Canada and I haven’t received a text message (I made sure to use the /canada). Textbelt returned success….

    Cool concept but I’m guessing not all of the networks play to well with third party texts (seeing as we wouldn’t be paying them).

    September 8, 2016 @ 11:59 pm | Reply
    • Same goes with me. It doesn’t send to my Bell phone :(

      September 12, 2016 @ 4:20 am | Reply
    • doghouch:

      @Jon It doesn’t work with my phone either :(

      (On Bell)

      September 12, 2016 @ 4:21 am | Reply
  3. Ant Stephenson:

    Although it appears I’m on the supported international carrier list, I didn’t receive the text message. :(

    September 9, 2016 @ 12:05 pm | Reply
  4. Graham:

    I tried sending SMS to a couple of United Kingdom numbers, one on T-Mobile and one on O2, nothing arrived despite the “success” response. Not a big surprise for a free service.

    September 11, 2016 @ 11:27 am | Reply
  5. Toine:

    Doesn’t work for french carriers either (said to be supported…)

    September 17, 2016 @ 2:03 pm | Reply
  6. If anyone uses Monit? Here’s how you can get notified by SMS when one of your Monit services goes down: https://blog.ss88.uk/monit-sms-notifications-textbelt-free

    September 29, 2016 @ 12:23 am | Reply
  7. will it work for india sms?

    October 11, 2016 @ 9:03 pm | Reply
  8. TextBelt seems awesome, I will definitely try it out.

    October 21, 2016 @ 3:00 pm | Reply
  9. J:

    This tutorial seems VERY broken and VERY outdated…. Either update it or remove it.

    April 14, 2019 @ 7:57 am | Reply
  10. Hi

    I’ll not waste your valuable time.

    The too long didn’t read version of this comunicado is that we have multiple clients in similar but non competing industries and we think you’d make a great link partner.

    So…

    Accepting any guest posts?

    Or have a resources page maybe?

    Or possibly could just edit a link into an existing page?

    Perhaps you too are looking to increase traffic and search rankings, it’s possible a link exchange with one of our sites is a good match for you?

    We’re open to anything really, if you’d like to discuss opportunities, just send an email to the submitted address and we’ll get right with you.

    If not, thanks for reading and best of luck. Happy interneting!

    Cheers!

    P.S. You really should reply, then I’ll reply back, then you can laugh at my funny profile picture. I’d explain further but it would ruin the surprise.

    March 9, 2020 @ 8:44 pm | Reply
  11. Carlos Villasmil:

    Before you run nodejs you must run: npm install or you will get:
    Error: Cannot find module ‘express’

    September 11, 2022 @ 9:06 pm | Reply
  12. Nice blog this types of blogs is needed so much fascinating i appreciate this blog

    December 29, 2022 @ 5:28 am | Reply
  13. paul:

    “Sending Your First Text Message from the Command Line” example is broken. API key now required.

    December 30, 2022 @ 10:52 am | Reply
  14. I learned that your articles’ contents and writing abilities are both consistently excellent. Thank you for providing this article; it contains information that is extremely important to me. so thankyu so much for a lovely content.

    February 22, 2023 @ 5:57 am | Reply

Leave a Reply to Marcus Cancel reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

Your email address will not be published. Required fields are marked *