Tips Tricks Tutorials

Send sms using perl

By using perl you can send sms simply using gateways. I am demonstrating using a gateway in linux environment. For more gateways click in the below link. I am using bulksms.com. For this you need to create a account in gateway

http://www.funsms.net/sms_gateways.htm

Now I am gonna demonstrate using Net::SMS::2Way module.

Steps

Create a configuration file, /etc/sms.cfg, which looks like this:

verbose = 1
logfile = /var/log/sms.log
username = webnesbay
password = webnesbaypassword

Note that your username and password is of bulksms.com
In your script you can add the following to import the Net-SMS-2Way module and create the object. Put this somewhere near the top:

use Net::SMS::2Way;
my $sms = Net::SMS::2Way->new({config => ‘/etc/sms.cfg’}) || die “FATAL ERROR: Could not create Net::SMS::2Way object!\n”;

Now we will right a method for sending the sms. The method that actually sends the SMS, send_sms(), is shown below

my $resp = $sms->send_sms(‘This is the SMS message!’, ‘3145206849′);
if ($sms->{error}) {
warn “Unable to send your SMS: ” . $sms->{error} . “\n”;
}

You should check the log file (specified in the config file) for errors/warnings if you are having problems. Read the Net::SMS::2Way docs for more examples. This is a little demonstration purpose. You can refer more on this below link

https://www.ohloh.net/p/net-sms-2way

You can leave a response, or trackback from your own site.

Leave a Reply

New Free AT&T Cell Phones for Sale | Thanks to Credit Card Offers, Bank Reviews & Ratings and Cheap Loan