Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

How to send text msg with perl??

by Niner710 (Sexton)
on Apr 30, 2008 at 01:56 UTC ( #683598=perlquestion: print w/ replies, xml ) Need Help??
Niner710 has asked for the wisdom of the Perl Monks concerning the following question:

I want to send SMS text messages to my cell phone with perl. Can anyone tell me how I would do that and what modules are easiest to do it with?? Any feedback would be greatly appreciated.

Comment on How to send text msg with perl??
Re: How to send text msg with perl??
by davido (Archbishop) on Apr 30, 2008 at 02:25 UTC

    There are SMS modules if you search CPAN, but with so many SMS servers already on the web, I would probably find one that doesn't mind you using it as a gateway, and interface with it via WWW::Mechanize.


    Dave

      Unfortunately for most "programmers", they resort to relying on modules for everything: Here's what I did to get this working in the past... but I must warn you.. that if US Cellular changes their page... it could break the script.

      If you view the HTML of US Cellular's SMS Gateway page (found on their website), you'll notice a random session number. You'll need this when you actually submit the request to broadcast the SMS.

      Second, you'll simply perform 2 "GET" or "POST" requests, but do whatever the form on their site does.

      Third, ensure you will pass the proper variables... such as the check box saying you have read the terms

      Fourth, be sure to set a referrer and user agent string in your script for the request to match typical behavior of any normal web surfer... such as a Browser user agent string found for IE, Firefox, et cetra.

      Fourth, don't ruin this for everyone. If they detect a tonne of traffic or abuse, they might decide to redesign their SMS interface to require a captcha... preventing you from developing a script and using it.

      Fifth, if you do abuse the system, I WILL HUNT YOU DOWN AND REPROGRAM YOU AND YOUR COMPUTER.

      If everyone is wondering why I didn't provide a script, it's because I see these things abused all the time... and if you are serious about using for personal use (instant notification of a successful telnet session... for example)... then you are definately smart enough to learn to use the LWP::Simple methods.. which are all you really need for this small task.

Re: How to send text msg with perl??
by mr_mischief (Monsignor) on Apr 30, 2008 at 04:02 UTC
    davido's advice is good, but there's an even easier way for most people. Find out from your cell provider if they support an email to SMS gateway, and what your email address for your phone would be. Then it's just using Net::SMTP or whatever else you use to send email to that address.

    I've been using this for years. My home router/firewall system sends an email to my email/SMS gateway when its public-facing IP address changes so I can always connect to my home network by IP.

    This service is usually pretty cheap. Your plan includes this if you're a U.S. Cellular customer, for example. Take a look at a list of SMTP to SMS gateways for different carriers and try yours out. You might have to call your customer service office to activate the service with certain carriers, even if it's free.

Re: How to send text msg with perl??
by Fletch (Chancellor) on Apr 30, 2008 at 04:03 UTC

    Also some cell phone providers provide a gateway for email messages so that you can send to NPA-NXX-XXXX@yourprovider.net (or some variation thereof) and the email will be forwarded to your phone. Check with your provider's web site for details what the exact address format is, and then you could use any of the various email modules.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: How to send text msg with perl??
by KurtSchwind (Hermit) on Apr 30, 2008 at 12:30 UTC

    You asked for SMS, and I'll give you the SMS answer, and then explain why those that gave you non SMS answers have better solutions. If you were on say, TMobile you could use something like SMS::Send::US::TMobile and there are some other phone carriers under the Net::SMS branch.

    Having said that, MOST carriers do not have public SMS gateways. They have private ones for pay. Why is that? Mostly we have the spammers to thank. When SMS gateways were public, phone customers started receiving 'stock tips' and what not. That's annoying enough, but getting charged for it was too much. Once the phone carriers started getting a deluge of phone calls they decided that public SMS gateways were the problem and just shut them down. SMS, by default, has less traceability than say email. This is why SMTP gateways are still public and that's why so many people use them to get to their phone. If your phone has email support, I'd recommend going that route.

    --
    I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.
Re: How to send text msg with perl??
by tubaandy (Deacon) on Apr 30, 2008 at 12:56 UTC
    For what it's worth, same thing goes for MMS. Using email to MMS via the recipient's email address (number@domain or whatever their MMS email address is) is your best bet.

    tubaandy
Re: How to send text msg with perl??
by adamk (Chaplain) on May 01, 2008 at 00:41 UTC
    You almost certainly want to write your code to use the SMS::Send API, and not just because I wrote it.

    There's a dozen backends for SMS::Send, and more keep appearing as the authors of other SMS sending modules write SMS::Send drivers.

    The main reason you want to do it is that you will almost certainly need to change your SMS sending channel a couple of times, and SMS::Send makes it very very easy to change the SMS delivery mechanism without having to change any code.

    Also, there's likely to be more SMS::Send tools appearing down the line, stuff like command line sending and a GUI SMS thingy.
Re: How to send text msg with perl??
by The Magnet (Initiate) on May 01, 2008 at 13:06 UTC
    Well, we collect cell numbers so we can send out text messages, which we have never done. How do you know the carrier? Most places do not ask this question. Can you send a text without knowing the carrier?? What about this module: http://search.cpan.org/~bigpresh/SMS-AQL-0.02/lib/SMS/AQL.pm ???

      The short answer is that you NEED to know the carrier to send an SMS (or email) message from the computer.

      Phone carriers exchange gateway and list information with each other, so sending a text message from one carrier to another is handled internally using dedicated gateways from one carrier to another. But if you were say, making a paging system and want to text cell phones when a job is complete. (or a file system fills up), then both the email and SMS gateways will require you to know the carrier. I know that where I work, they ask for the phone number and carrier and then that determines the message delivery. Sometimes it's SMS, sometimes email. It all depends on who has a public gateway and what it is.

      --
      I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.
        So, if I understand correctly, there is no gateway which will say, test all carriers for you or something. You'll need to know there carrier so it knows how to send it, etc. Ok, the of course my next question, are there any free gateway providers??
Re: How to send text msg with perl??
by Anonymous Monk on May 05, 2008 at 02:54 UTC
    sendSMS.pl works for me (it accesses various providers Web gateways). I will be checking out some of the suggestions here though.
      Ok, thanks for all the good feedback. I ended up just doing what KurtSchwind recommended. I was able to get my script to work using the MIME::Lite module. I have sprint so was able to send email to mynumber@sprintpaging.com. I had trouble sending to a cingular number. It seems like they keep changing their email addy to send it to though. Thanks again for the feedback from everyone
Re: How to send text msg with perl??
by blazar (Canon) on May 10, 2008 at 14:51 UTC

    I personally believe -given that you ask here how to do that in Perl- that you're not the guy from a famous WTF, who insisted asking how to do the same thing in Java. Or else... are you that famous Java guy, who turned to Perl? ;)

    --
    If you can't understand the incipit, then please check the IPB Campaign.
Re: How to send text msg with perl??
by rgcosma (Beadle) on Feb 23, 2011 at 22:31 UTC
    You should use Gammu, it is cross-platform and its developers have taken care of all the low-level communication with the device. You can bactick it or of course read the source and figure out a better way to integrate its lib with perl.
    Its configuration is as simple as (on Windows)
    [gammu] Device = com16: connection = at
    and afterwards
    gammu sendsms text +12345670 -text "hello world"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://683598]
Approved by grep
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2014-11-26 23:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (176 votes), past polls