Send an SMS Text Message from the Command Line

Mar 12, 2014 - 53 Comments

Send a text message from the command line When you think of sending out text messages you probably think of the iPhone or an Android, and the command line doesn’t cross your mind, but thanks to the ever-useful curl command, you can send out a SMS text message to any phone number right from the Terminal.

Yes, curl, the same command line tool for transferring data to and from URL’s, downloading files, getting HTTP header details, and so much more, can send text messages. This is done through a POST request sent to the TextBelt service, a free outgoing SMS API. Sure there are limits, but they’re fairly generous at 75 texts per day (per IP), and you can’t send a number more than 3 texts in three minutes to prevent abuse. Aside from that, keep in mind that you’ll be charged for incoming texts at the regular SMS / texting rate from your cell provider – this does not use the iMessage service – so don’t overuse this if you don’t have an unlimited traditional texting plan.

Sending a Text Message from the Command Line with curl

The basic syntax to use is as follows, be sure to replace the ########## with your own 10 digit phone number (10 digits = area code + phone number), and then replace the message= text with your own message to send:

curl -d number=########## -d "message=text goes here"

For example, to send a text saying “hello from” to the phone number 555-155-1555 (not a real number), you would use the following command string:

curl -d number=5551551555 -d "message=hello from"

Yes you could put another persons phone number in there too, but you probably should not do that without their permission.

If the text was successfully sent, the command line will return a message stating ‘{“success”:true}’, if it fails for whatever reason, it’ll look something like the following, which is usually indicative of an error in your command syntax: ‘{“success”:false,”message”: “Number and message parameters are required.”} curl: (6) Could not resolve host:’ Just review the command string and try again.

The text message should arrive to your iPhone or Android very quickly, though the expedience of the service likely depends on a queue and how much activity TextBelt is receiving from elsewhere. It’ll come through looking something like the following:

SMS texts on an iPhone as sent from TextBelt command line service

(If you’re wondering, responding to the texts goes nowhere and does nothing, it’s not a 2-way service)

This works to send texts from Mac OS X, Linux, and presumably whatever other OS or service has curl access. The recipient side should work with any mobile phone that accepts SMS, whether it’s an iPhone or an ancient brick Nokia.

Adding a Quick ‘Send Text’ Command to Bash

If you enjoy the convenience of sending yourself texts from the terminal and plan on using this often, you can create a simple bash script to shorten the command string by adding the following to your .bash_profile. Be sure to replace the number with your 10 digit phone number:

sendtext () { curl -d number=5551113333 -d "message=$1";echo message sent; }

With that in your bash_profile, you can simply type “sendtext your message goes here” to send out a text to yourself. This also allows for some fun and utility with double ampersands &&, like sending yourself SMS alerts when a software package has finished installing, or when a remote file is done downloading. Those with command line experience can probably think of a million and one other handy uses for this as well.

According to TextBelt, the service definitely works within the USA with the following cell networks: Alltel, Ameritech, AT&T Wireless, Boost, CellularOne, Cingular, Sprint PCS, Telus Mobility, T-Mobile, Metro PCS, Nextel, O2, Orange, Qwest, Rogers Wireless, US Cellular, Verizon, Virgin Mobile. This may be limited to the USA, but we’re unable to test networks outside of the region, let us know if you give it a try elsewhere.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS X, Tips & Tricks


» Comments RSS Feed

  1. Mike says:

    Wow this is cool, great trick!

  2. Kayne says:

    Doesn’t work on Polish numbers (here we have 9 digits number and 2-3 for country code). So it returns {“success”:false,”message”:”Invalid phone number.”}.

    • Junior Jr says:

      It works in USA and Canada only, apparently. Maybe Mexico too if you can stay on a US cell tower, heh.

      Anyway, this is cool, I will use it for notifications!

  3. Leslie says:

    Maybe only in the US.I tried to send to a swedish mobile but I got “Invalid phone number”

  4. joe user says:

    now could a spammer use this? send out hundreds of these things. no trace back only the poor site that just get bombarded by text messages…

    i could see it now
    MSG:Sign up for Russian brides at http://www.fakewebsite.scammer

    • Junior Jr says:

      Probably not with “75 texts per day (per IP)”

      If you’re a bulk SMS sender, there are services which offer many thousands a day. Or you can just use AIM (yes, AOL Instant Messenger! LOL!!!), because you can send endless texts through the AIM service by prefixing a message with +1

  5. Marc says:

    Worked for AT&T of course, but did not work for my Google Voice number. :(

  6. @ngel says:

    Doesn’t work in the UK either

  7. Corrie says:

    The textbelt website confirms that they only support some US carriers (network operators).

  8. Chris says:

    Does not work in Germany:
    {“success”:false,”message”:”Invalid phone number.”}

  9. Tedy says:

    Apparently it doesn’t work for Indonesian number with 62 prefix

    {“success”:false,”message”:”Invalid phone number.”}

  10. Luis says:

    Doesn’t work in Spain either : /

  11. mobilio says:

    This is same gateway that we use for SendSMS app

    But you’re correct – works only on few US and Canada operators.

  12. Federico says:

    Who are the people behind why should we trust them?

    • Don says:

      Exactly what do you need to trust them with? The destination phone number? The message? I simply wouldn’t text anything this way that I wasn’t prepared to be seen by at least some people, if not the world. But that’s largely my attitude about any text.

  13. Romeo says:

    Ukraine, doesn’t work :(

  14. Me says:

    Is there a way too to send a fax with Curl?
    Would be cool!

  15. Tim says:

    Some carriers (like Verizon) allow blocking of texts from the web and email. If you have that turned off, you won’t get these.

  16. Jason Tsai says:

    doesn’t seem to be working here in Toronto.

  17. .- says:

    The title “Send an SMS Text Message from the Command Line” is misleading. It should read “Using a web service from command line”. The command line does not send a text in this case.

  18. Pol Wirtz says:

    Doesn’t work in Luxembourg – but anyway: the “regular” approach is so much simpler to me :-) !

  19. Brett Rossi says:

    would you mind if I post this on twitter?

  20. Mike says:

    The source code on GitHub suggests you can also do this yourself without having to go through TextBelt

    where %s = your phone number

    list: [
    //’’, // slow

  21. Vijay says:

    If you want this to be even cooler, put this in your bash_profile:

    sendtext () {


    curl -d number=$1 -d “message=$var”;
    echo message sent;


    This allows you to type “sendtext typephonenumberhere write your message here”. This way you can send custom messages to custom numbers without having to change your bash_profile every time!

    • Douc Gleason says:

      I like this idea and so I am using it with vim but now I am stuck and can’t quit out of vim. Ended up using kill -9 LOL!!

      Why is vim the hardest thing ever? I guess I’ll use something else…

      • Paul says:

        We see this question a lot, the easiest way to quit out of vim is: Escape, SHIFT ZZ

        Write-up coming up, I think it will help many. Generally most users are better off using nano or, depending on what they’re editing, even TextWrangler in the GUI.

  22. Bob says:

    Does not work with Australian numbers.

  23. Sam says:

    Doesn’t work on Mars either :-(

  24. Pluto says:

    Not working on Skype US numbers….

  25. David says:

    How can I get the curl program? How much?

  26. James says:

    Too bad this unnecessarily requires a third party service –

  27. robert says:

    Thanks, FYI this does not work with phone numbers from Uruguay.

  28. robert says:

    Thanks, FYI this does not work with phone numbers from Uruguay like :
    01159899085323 where :
    011 means :outside north america
    598 means : uruguay
    99 : means “antel” cell network
    the rest is the phone number.

    If anyone finds a way to send a text to that number, let me know please. I’d also like to find a way to reply with a code so that I can use it for remote monitoring and control.

  29. mdhuss says:

    How does it know which service to pick for a particular U.S. phone number? For e.g., my number has been ported all the way from At&T to T-Mobile to MetroPCS.

    I did not receive the message when I tried this service, though I see {
    “success”: true

    But I was able to receive the message when I directly emailed

  30. Zhak7 says:

    Exactly what I was looking for. Unfortunately it doesn’t seem to work in France :/
    Dial code for France is +33, 6 (or 7) indicates a cellphone, so I wrote:
    curl -d number=+336xxxxxxxx -d “message=Is this really working?”
    Am I missing something or it’s purposely not working for other countries.

  31. David says:

    Aside from sending SMS from the command line, or the SendSMS Mac app (previously mentioned in one of the comments), you can also find some other Mac options now:

    * Safari browser extension
    * Mac OS X desktop widget
    * other browser extensions (Chrome, Opera, Firefox)

    find them here:

    And if this service not working so well for you and you can deal with CAPTCHA, then try this alternative option (no command line access due to CAPTCHA):

  32. Allen says:

    i have not received any of my 100 text sent to my gv or my tmobile account.. is this still working

  33. AK says:

    Is this still working?
    It doesnt seem to send text messages when I tried to US #’s.

  34. vb says:

    Its not working in India either.

  35. Jo Creyf says:

    Kind of interesting to delve through this TextBelt code and to learn how they get SMS messages sent out.
    I’ve been struggling at my work to get automated monitoring SMS alerts sent out to on-call phones through our mailserver because of security constraints and have been looking for workarounds. I thought to have found the solution here through curl but turns out this TextBelt REST service is using the Mutt email client in its belly to do the heavy lifting. So it would still come down to having to go through our mail server and thus hitting that same security restriction.
    Too bad. It looks like a great service and nicely coded! Congrats to TextBelt!

  36. Jo Creyf says:

    To all people complaining about this not working in their country or no longer working … why not clone the project and set up a server in your own environment?
    TextBelt has done a great job in clean development and documenting. This is easy enough to clone and customize to your own likings.
    Or even better yet … update their code on github and see if they are willing to deploy your stuff in their production server.
    In the end, if you want to run this yourself, all you need is an email client that is configured to connect to some mail server.
    Phone providers tend to change their endpoints every now and then, breaking the TextBelt REST service. It’s easy enough to update the TextBelt configuration files to get it working again (unless of course if the phone provider decides to stop providing the email to SMS service, which has happened to me a couple times in the past).

  37. Ravi says:

    its not working for me i didnt get any message

  38. Djbravo says:

    Its not working here in moon

  39. Makah says:

    it worked perfectly for me, however, it is no longer free. They now require an authorization key and have a pricing structure:

    $ curl -d number=########## -d “message=This is a test”
    {“success”:false,”error”:”This Textbelt endpoint now requires a ‘key’ param. Please go to to sign up for an API key.”}

    (phone number replaced with #’s for privacy)

    Pricing tab on their website shows :
    $3/20 texts
    $5/100 texts

Leave a Reply


Shop on and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks


iPhone / iPad



Shop on Amazon to help support this site