Tips Tricks Tutorials

WEB-NES-BAY

Learn Tips and tricks on Linux, Hacking, linux, PHP, Perl, Web, Hardware

bookmark bookmark
WEBNESBAY On July - 9 - 2009

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

Related posts:

  1. send email with attachments in perl
  2. Run IMAP with PERL
  3. Send and Receive Hotmail through Evolution in ubuntu
  4. Sockets and TCP/IP Networking using PERL
  5. Send messages from Ubuntu to Windows over LAN
  6. User defined exceptions in python
  7. Special shortcuts in Perl
  8. Perl script for search & replace in several files
  9. Perl Server Side CGI Scripting
  10. Create PDF using perl
Categories: Perl

Leave a Reply