content developer build share monetize content developer logo content developer masthead bottom

Open Source SMS Text Messaging Application

I recently built a basic text message delivery application designed for a local broadcast television station to send breaking weather and traffic alerts to the mobile devices of subscribers to the free service. I learned some things along the way and wanted to share a quick overview of how the application was put together.

First, this approach is designed for those wanting to deliver SMS text messages in the United States. In the US, the system is open to senders to send text messages to mobile devices with no charge to the sender. Those on the receiving end of the text message are billed according to the particular service plan they have with carrier. The main point to remember here is that those who receive text messages are usually billed in some form or fashion so be sure they really want to receive what you are sending.

I believe SMS billing is handled differently is many overseas markets, where both the sender and receiver are billed, so be sure and investigate for yourself if you are outside of the US.

The US mobile carriers make it possible to do this because each mobile device has a unique email address that when delivered through the providers website will be sent as an SMS message to the mobile device. Note: this email address is different than the standard email address many mobile devices are also issued. For all of the carriers the addresses are constructed pretty much the same way.

10 digit mobile number at special sms address .com

For instance, ‘s special SMS messaging address is

messaging.sprintpcs.com

So, a Sprint mobile user with the phone number 123 456 7890 could be sent a SMS text message at the address

1234567890 @ messaging.sprintpcs.com

A somewhat comprehensive list of these SMS addresses for US mobile carriers can be found here among other places.

OK, so now that we know how to communicate with the mobile device the next step is to build a couple of small applications with and that allow your customer or audience to sign up and receive your mobile alerts. Please remember, MOBILE ALERTS ARE OPT IN ONLY. Spam is evil whether it is delivered to your inbox or your phone.

First — the signup form:

To get started, on a virtual server I used to create a new MySQL database called newsalerts. In this database I created a table called subscriptions. In this table I created 3 fields: mobilenumber, provider, smsaddress.

From there I used PHP to build the database front end sign up form. Here’s a screenshot:

mobile-alerts-signup-exampl.jpg

This is a relatively straightforward PHP database signup application with a little extra bit in there that combines the three sections of the phone number, adds an @ sign and the carrier address info to create the complete SMS address for that device.

The second part of the process is an application that allows the meteorologist or traffic reporter to enter a message title and the text message to send. When they press send, the application will then loop through the database of subscribers and deliver that message they created via SMS to each subscriber.

Here is a screenshot of this part of the application:

mobile send example.jpg

The message can be up to 160 total characters in length (assuming 7 bit characters). The user can also simply send a URL link if they want to send the subscriber to a more graphically rich mobile site that might include a radar map or a picture of an auto accident.

IMPORTANT — anyone with access to this part of the application can send alerts to all of your customers so if you are building something like this you will definitely want to use or some other method to password protect this part of your application.

Both parts of this application use the open source application to handle the mail process and rely on PHPMailer’s class.phpmailer.php.

Now for a couple possible downsides to this approach:

First, most of the mobile carriers warn that SMS text message delivery using this process can be delayed, but with all my tests to date, delivery of the text message has taken less than two minutes, most all under a minute and many times delivery to the device is just a matter of seconds.

Second, as stated earlier, you are restricted to sending only 160 characters of text via this method. No messaging via these protocols. This does limit you somewhat but doesn’t really strike me as an obstacle since if your content involves more than just text, then you can simply send your user a link to your rich mobile content that they can then download. This seems like a reasonable workaround in most cases.

To recap, by taking advantage of open source tools and techniques like these just about any type of content developer or small business can take advantage of mobile devices to help build relationships with your audience or customers.

And here’s a thought, if your business model involves your audience or customer paying to receive your content, then you can team this approach up with the and you are ready to go with an entry level SMS content distribution strategy.

Update: If you’re working on delivering audio or video to mobile devices, be sure and read about the mobile carriers and devices we tested in the post

gray line

Filed under distribution by david cummings on Thursday 1 June 2006 at 9:10 am

  |  

39 Comments »

  1. Comment by Matt Beeman — June 13, 2006 @ 12:20 pm avatar

    We have been experiencing problems specifically with Sprint phones receiving our text messages. Have you found any particular problem with sprint phones?


  2. Comment by David Cummings — June 13, 2006 @ 5:55 pm avatar

    I’ve had good luck with Sprint as far as receiving messages sent with this app and knowing what to do when you only send a link.

    Not sure it is related to the issues you are running into with Sprint, but there is a conversation going on in the Sprint Developers Forum (developer.sprint.com) about some changes Sprint may have made in their WAP Gateway and its impact on some WAP sites.

    One situation that has surfaced is the way some carriers and devices appear to handle any links that are sent via SMS. In some of the carriers on some of the devices that have been tested so far, URL’s aren’t hot when the user opens the SMS message and need to be cut and pasted into the phones wap browser. It appears to be the minority of cases, but that is something that has popped up.


  3. Comment by Travis J. James — September 14, 2006 @ 1:14 pm avatar

    This is a great article. I implemented something like this myself, but there were a few limitations to get around, and I would like your input on how you handled these:

    1. This solution requires that you know the carrier as well as the phone number, so you can locate the right SMTP server. Because of this, the user wishing to receive the message must subscribe first with this information.

    2. Because users can change networks now without changing their cell phone numbers, this makes it difficult to keep this information in sync unless the user helps.

    3. If you wish to implement something that allows the user to send text messages to any number (not just ones that are registered with your application), they must know the carrier.

    Have you found any solutions to these problems that don’t involve purchasing expensive libraries that basically hard code the SMS gateway addresses (and thus can get out of sync and require lots of maintenance after you pay a lot of money)?


  4. Comment by David Cummings — September 16, 2006 @ 1:51 pm avatar

    Hi Travis:

    Thanks for the questions. You’re right on target. When the subscriber signs up they have to provide their mobile number and the mobile carrier they are with and if they move their number to a new carrier then they need to update their subscription.

    Have not found a way around this, but for apps in the subscription/registration model (paid or free) and within a certain scale the tradeoffs seem manageable. In the scenario that you give in example 3 with an open setup with no registration, no knowledge of the carrier and a potentially very large scale this approach no doubt becomes difficult if not near impossible to implement.

    To use this open method for delivery, one way or another we need a database of phone numbers with corresponding mobile carriers. Either the user provides that info or we have to get it from somewhere else. If there is a reliable, manageable and affordable method of deducing the carrier (and therefore the delivery address) from the phone number alone that would be a huge plus. Since the FCC passed local number portability
    that seems like a pretty big challenge though. What was once a landline could now be a Sprint phone that will tomorrow be a Cingular phone. Or vice versa.

    If you find workarounds or new approaches that improve these areas I would very much like to learn about them so please check back and share what you find.

    Good luck with your app Travis.

    DC


  5. Comment by Ian Warshak — December 8, 2006 @ 8:50 am avatar

    Hi David,

    I found your blog posting about your SMS messaging solution in the strangest way. It started out I was looking up information about ATT’s U-verse here in San Antonio. I found satechblog.com, and then somehow I found contentdeveloper.com.

    Anyway your posting about delivering SMS messages immediately caught my eye. The reason is, I have done the exact same thing. In fact, my company’s business is based off of sending SMS alert messages (emergency school closing information). I live here in San Antonio,
    but emergency school closings happen a lot up north, so getting this information to parents in a timely manner is important. It’s not that
    critical in south Texas.

    Anyway, for our first attempt at SMS messaging I did exactly what you described. That is, using the carrier’s email -> SMS gateway. The
    problem was that the carrier’s gateways can be very sensitive, and start blocking your messages if they suspect it may be spam (since the user bears the cost). We were sending thousands of alert messages, and carriers (verizon in particular) started to block us. We were able to get temporarily whitelisted, but in the end we chose to go with a true SMS aggregator in order to more reliably send these messages.

    I learned WAY more about SMS messaging than I cared to, but it is working for us now :-)

    Anyway, I just wanted to share that. I thought it was interesting that there was more than 1 person in San Antonio that developed such
    similar SMS alert mechanisms :-)

    I will add your blog to my newsreader. Glad I found it!

    Ian

    (note: Ian sent these comments as an email but I wanted to share them here as I thought it might be helpful to alert you to some potential roadblocks with this approach if the open source sms service you are building is going to scale beyond a small to medium sized audience. Thanks Ian for letting me post your email and share your experience. DC)


  6. Comment by John Garrett — December 8, 2006 @ 4:20 pm avatar

    Ian,
    My business will be sending out SMS alerts and we’re trying to determine how far we can go using the carrier’s email. How much message volume did you have when they started blocking you? Who did you speak with at the carriers to get whitelisted, and how much message volume did they allow at that point before you had to get provisioned with a short code?

    Thanks!
    John


  7. Comment by ian — December 10, 2006 @ 4:33 pm avatar

    John – There is no exact number, but we were sending out thousands of alert messages. Verizon seemed to be the most sensitive.

    Ian


  8. Comment by dave — December 29, 2006 @ 5:08 am avatar

    hi,

    your project seems very interesting. i saw this while researching for info on sms based application developing. i’ve recently made an app, on c# though, same as yours, can send and receive sms. i also used a gsm modem as the hardware part of the app.

    maybe we can share insights on developing sms based applications

    keep up the good work!

    dave


  9. Comment by James — June 27, 2007 @ 5:01 am avatar

    hey
    actually i had to make an application similar to this one sending messages at mobile networks, ok, i just read this article and that php and mysql thing is so simple will do that in 15 minutes, but i was just wondering what’s the actual code you wrote in php for sending those sms alerts/messages to all the email addresses in your database. kindly let me know as soon as possible


  10. Comment by Chris — August 27, 2007 @ 9:46 pm avatar

    Thanks a lot for the insight into problem I have been trying to figure out.

    How would one unsubscribe, directly from their phone?

    For instance most SMS stuff uses a 4-5 digit number. “text unsub to 23232″

    Without this capability in your method, how do you deal with people who want to unsubscribe?


  11. Comment by John Bolder — September 8, 2007 @ 2:22 pm avatar

    Hi Guys

    You may want to visit http://www.mysmsaddress.com or virtualtextmessenger.com for your group SMS requirements its a real SMS Gateway


  12. Comment by dc — September 12, 2007 @ 7:15 am avatar

    >>How would one unsubscribe, directly from their phone?…Without this capability in your method, how do you deal with people who want to unsubscribe?<<

    No doubt Chris. This is one of the challenges of this approach.

    Current options for handling is letting the user unsubscribe via email sent from their phone or from browser at a URL. For users’ with newer phones, this works pretty well. Older phone users can accomplish from desktop.

    Certainly not as elegant as texting “unsub” to a short code, but for a content developer with a small to medium size user base, a work around that perhaps some can live with.


  13. Comment by Scott — September 26, 2007 @ 9:16 am avatar

    Hi David,

    I really enjoyed reading your post on the SMS handling system that you developed. I’m not a developer, but I’d like to create an application that allows users who sign-up via the web to receive group text messages from computers or mobile phones (also communicate via email) and have a reply-all feature on their phone. I’d like to partner with a developer / programmer….what programming languages are necessary?

    Also, do you think that I should go the route of an SMS aggregator or develop our own system? If I develop my own system, how much will it cost to receive text messages? The aggregators charge one to four cents to send / receive messages.

    I appreciate any insight that you can provide.

    Best regards,

    Scott

    (note: Scott sent this via email earlier this week, and with his permission I’ve posted his questions here. Many content developers are evaluating the same decisions and it would be interesting to hear about the different directions people are going with, and why. Thanks Scott. DC)


  14. Comment by Emmett Lunceford — January 10, 2008 @ 9:59 pm avatar

    David,

    I’d like to host an app. which would have the ability to allow the client to schedule 1) phone reminders 2) email reminders 3) SMS text message reminders.

    Do such an application already exist in the marketplace? Thank you in advance for your reply.

    Emmett


  15. Comment by dc — January 19, 2008 @ 3:54 pm avatar

    Hi Emmett:

    I don’t know of an open source turnkey app available that you can download, install and be up running right away doing exactly what you are after…yet

    One approach some people have taken — many of the calendar apps have this functionality or something close to it built in. Many of them also have their API’s available to build your own add ons or hook into.

    Backpack comes to mind.

    http://backpackit.com/

    Good luck, and let us know what you find.

    DC


  16. Comment by Mike Foland — March 18, 2008 @ 4:25 pm avatar

    Hello,

    I am trying to build a school closings system with NWS advisories map, php scroll, etc… plus a school closings area so that schools can post closings, and then they show up in a special format on the public side. I already have some of the interface done, just now trying to do the school closing part. I also want my closings to auto expire.

    How do I go about this using MySQL and PHP?

    Thanks,

    Mike


  17. Comment by dc — March 20, 2008 @ 10:30 am avatar

    Hi Mike:

    You may want to take a look at what Ian is doing at School’s Out and Campus Wire.

    http://www.schoolsout.com/

    http://www.thecampuswire.com/

    Good luck with your project.

    DC


  18. Comment by Craig Sour — April 25, 2008 @ 9:12 am avatar

    Ian,

    Great to see good feedback on a technology such as SMS on your site. SMS is quickly becoming a common tool of use in our daily lives. This is proven by the recent unlimited everything offers from all the carriers.

    My question is this:

    Is there a way to house your own SMS gateway solution and effectively reach your targeted audience. We are looking at providing a service to communicate with thousands of people daily but the volume varies day-to-day.

    Do you do anything with MMS? I would really like to explore this but am told that we should build a custom application for phones to do this…what do you think?

    Craig


  19. Comment by ian — April 29, 2008 @ 10:20 pm avatar

    Craig, I haven’t done anything with MMS.

    I am currently using clickatell.com for my SMS delivery.

    Housing your own SMS gateway requires direct connections and agreements with the major carriers. This is probably cost prohibitive to most companies.


  20. Comment by Brian Caine — April 30, 2008 @ 5:00 pm avatar

    Great idea. I was looking for SMS info and finally stumbled across your post. I am a school teacher who is looking for ways to successfully implement cell phones in class, so our district will get over its arcane policies, and was wondering if someone would care to help a relatively novice programmer set up a system. I am strong with basic web programming, but novice with SQL and PHP, my remotely hosted site has plenty of options for the database, but any help/walkthrough would be much appreciated.


  21. Comment by Anu — May 28, 2008 @ 11:55 am avatar

    Hello Ian,

    I am working on an SMS emergency alert application for my school and we are looking into using Clickatell. How happy have you been with their service? Any complaints? Would you recommend them? Do School’s Out and CampusWire both use Clickatell? I am trying to grasp the whole setup and I am wondering why should one use these when they can directly sign up with Clickatell? Could you clarify that for me?

    Thanks,
    Anu

    BTW, great post DC.


  22. Comment by Matt — June 13, 2008 @ 11:24 pm avatar

    Hi, David;

    Great and helpful site. I was hoping that you could provide a little more help in the form pointing me in the right directions.

    I have sms content that I believe people will be willing to pay for, per sms. Ideally, they would send a request via sms, and they would then receive my content via sms. They would pay for it, and I would get a cut, per sms.

    Do you know of any services that can help me with this (I imagine they will take a cut, or include advertising)?

    Not ideal, but if that doesn’t work, is there a service that will set up my content to be delivered once a person subscribes, and pays a monthly fee?

    I am new to the sms business and technology side of things, but have killer content to get into the hands of users, and need help with how.

    Thanks so much for any and all suggestions,

    Best,

    Matt


  23. Comment by Roy — September 12, 2008 @ 12:21 am avatar

    My son’s teacher would like to be able to send short text messages to students. I’m looking for a simple solution that would allow him to broadcast to 20-40 students a “reminder” about class info. This article looks very promising, but It appears to be server based. Can this type of program be modified to run run stand-a-lone, ie flash drive, desktop…?


  24. Comment by JustUs1776 — September 15, 2008 @ 1:21 pm avatar

    Great post. I’m a LAMP Developer and I was wondering if anyone has been able to build their own GSM server. That is, a server that can utilize a GSM modem to send direct, local messages to cell or IP phones. I’m working for a not-for-profit health care organization and have a suite of applications that I’d like to improve communication turn around time by sending SMS messages our nurses IP phones and our Physician’s cell phones. I’ve found a ton of services that are all cost prohibitive and was hoping for an open source solution.


  25. Comment by Kyle2008 — October 13, 2008 @ 1:45 pm avatar

    Great post DC. Very interesting approach to sending SMS. Is the source code for this actually available anywhere?

    Thanks!


  26. Comment by Creg Fielding — October 20, 2008 @ 9:43 pm avatar

    TxtWire has a web service that will return the cell phone carrier. Just pass it a phone number and it will tell you who the carrier is even if the phone number is ported from one carrier to another. Our database is updated daily so even numbers that are ported today report correctly tomorrow.

    If you would like a demo account call. We have several large corporations and online software vendors using the service.

    cfielding@txtwire.com
    http://www.txtwire.com


  27. Comment by David Johnson — February 16, 2009 @ 10:14 am avatar

    Would you be willing to share the code you wrote so we can use it?


  28. Comment by tom — March 19, 2009 @ 1:48 pm avatar

    Thank you for your post.

    My workplace is interested in being able to do more with SMS, but, I hear that previous attempts at your approach have seen problems with spam filters blocking the messages. (This could be caused by the fact that we had been an ISP for 10 years, and were the AOL of hte local scene).

    My question for you is this: Have you had much problem with messages not getting through, because they were rejected as spam? What did oyu have to do to correct it?


  29. Comment by Robert Thiele — June 5, 2009 @ 3:05 pm avatar

    A Linux SMS virtual appliance management server that is teacher controlled. Wireless Test Administration for K12 and beyond.

    http://messaging4education.com


  30. Comment by jackson — September 25, 2009 @ 6:57 pm avatar

    hey there, have been messing around with phpmailer for awhile, and found your site while looking for a solution to a problem:

    international characters not displaying when emailed. when phone returns and email, writing international chars with it’s own keyboard, likewise not displayed in email

    i believe this is an issue with the GSM charset, eg: it’s needed to be able to send readable sms to phones (gsm charset supports international chars) have tried changing content type, encoding and numerous other things, would appreciate any ides you may have, feel free to email,thanks


  31. Comment by dc — January 27, 2010 @ 11:08 am avatar

    Quick update – If you use WordPress, there look to be some interesting plug-ins available now that take advantage of this same approach for delivering SMS messages via email.

    I downloaded one – EasySMS – and plan to test it out.

    http://wordpress.org/extend/plugins/easysms/


  32. Comment by Garry — February 8, 2010 @ 12:33 pm avatar

    Hey David,

    THis is exactly what I was looking. It’s good to hear it from someone that’s done this in the real world too.

    Cheers,
    Garry


  33. Comment by Steve — June 30, 2010 @ 11:41 am avatar

    Did you release this code? I could use this.


  34. Comment by Morgan — July 2, 2010 @ 9:09 pm avatar

    The company I work for is a non-profit organization that drives intoxicated people home with their vehicles. The service is so far a success but we are having some dispatching issues. I’m looking for a program that can send an SMS message to the drivers once the ticket is submitted and log everything into an SQL database that also keeps track of the customer’s variable information. Again, this is a non-profit organization so funds are severely limited. Any help would be greatly appreciated. Thanks!

    Morgan


  35. Comment by Wes — July 28, 2010 @ 10:52 pm avatar

    Hey thanks so much for the AWESOME post! I found it to be very informative. I am looking to create a SMS gateway app, and this solution seems like it will be what I need for the time being. One question I had though is about using short codes. The approach you have outlined is basically the way that you can do SMS messaging without the use of a short code, right? If I were to want to setup this service where they can opt in via short code, is that a lot more involved? I guess I could just have them put an email address in the to: part of an SMS message…is there a simple way to implement this type of simple service with a short code? Thanks!!


  36. Comment by Bill — October 6, 2010 @ 12:05 pm avatar

    If the text messages are send via email to carriers’ messaging email addresses, how do you handle sending such a high volume of email messages? Many hosts limit the number of emails you can send. Thoughts?


  37. Comment by Jeff Davis — July 28, 2011 @ 12:44 pm avatar

    Very interesting. Would LOVE to see the code. We’re a school district with around 2800 students. Most of the vendors selling this sort of service are fiscally proud of their products, and with the ever-shrinking budget, getting more and more difficult to fund such things.


  38. Comment by kay — August 26, 2011 @ 9:21 am avatar

    It was nice to find this post as I’m looking into a value added service for our Emergency Communications. Using SMS and email distribution of alerts in case of mass emergency (hurricane/earthquake/fires/evacuations etc) to supplement our current system (which uses a dialer). This post gave me some good ideas along with the wonderful input in comments. Thanks!


  39. Comment by Noel @ Mosio — September 12, 2011 @ 11:19 pm avatar

    This is great, David, even more relevant than when you originally created it! Have you found any information on rate limiting from the mobile carrier side of things? They are obviously keen at avoiding spam and one of the main reasons businesses need to use a short code is for higher volumes of texting. Obviously for lower volumes your system could work, but I’m curious if you have any information about the “breaking point” in number of outbound messages to a specific mobile carrier.

    Thanks!

    Noel
    CEO, Mosio
    http://www.mosio.com


RSS feed for comments on this post.

Leave a comment

Next article: Click.TV
Previous article: Disappointed Spurs fans might enjoy this viral video.

spacer

More Fresh Content -- The Latest Activity on the Content Developer Network.

spacer

jobcoin icon Content Developer Jobs

see more jobs...    submit a job...

delicious icon Content Developer Bookmarks

Citizen Media Law Project
The mission of the Citizen Media Law Project is to provide assistance, training, research, and other resources for individuals and organizations involved in online and citizen media. Affiliated with the Berkman Center for Internet and Society and the Center for Citizen Media. Bookmarked 09/13/2011.

The MobileESP Project
MobileESP is an open source project designed to provide web site developers with a lightweight API for detecting whether visitors are using a mobile device, and if so, what kind. Distributed under Apache License 2.0, source code is available in PHP, Java, APS.NET, Ruby and JavaScript. Bookmarked 05/25/2011.

Open Journal Systems
Open Journal Systems is a free, open source solution for managing and publishing scholarly journals online. Developed by the Public Knowledge Project, OJS seeks to improve the editorial process through innovation and make open access publishing a viable option for more journals worldwide. Bookmarked 04/15/2011.

International Digital Publishing Forum
The International Digital Publishing Forum is an organization dedicated to the development and promotion of electronic publishing and content consumption. The IDPF maintains the EPUB content publication standard for creating and distributing digital books that can be accessed across EPUB-compliant reading devices and applications. Bookmarked 01/21/2011.

ThinkUp
ThinkUp is an open source social media insights engine that captures your conversations on social networks like Twitter and Facebook and stores that information in a database you control. Provides ability to manage and visualize your social data in various ways. Bookmarked 01/14/2011.

more del.icio.us bookmarks...

spacer
Content Developer was founded by , a San Antonio Web Developer & Freelance Content Strategist focused on using open source software to build, share and monetize multi-platform, interactive content; and how sharing knowledge via & can be used to help grow authentic brands. Learn more.

Content Developer is powered by Wordpress & Your Web Server. Content Developer and build. share. monetize. are trademarks of Cummings Hatton Corporation.