Perl Script to send Free SMS to any mobile number in INDIA using way2sms

2009
02
Dec
9

The following script sends SMS to any number in INDIA using the free service provided by Way2Sms.com
Requires WWW::Mechanize and Compress::Zlib libraries.

Please remember to fill the username and password in the fields that is mentioned in the script.


#!/usr/bin/perl
 
use WWW::Mechanize;
use Compress::Zlib;
 
my $mech = WWW::Mechanize->new();
 
my $username = ""; #fill in username here
my $keyword = "";  #fill in password here
 
my $mobile = $ARGV[0];
my $text = $ARGV[1];
 
$deb = 1;
 
print length($text)."\n" if($deb);
 
$text = $text."\n\n\n\n\n" if(length($text) < 135);
 
$mech->get("http://wwwl.way2sms.com/content/index.html");
unless($mech->success())
{
	exit;
}
$dest = $mech->response->content;
 
print "Fetching...\n" if($deb);
 
if($mech->response->header("Content-Encoding") eq "gzip")
{
	$dest = Compress::Zlib::memGunzip($dest);
	$mech->update_html($dest);
}
 
$dest =~ s/<form name="loginForm"/<form action='..\/auth.cl' name="loginForm"/g;
 
 
$mech->update_html($dest);
$mech->form_with_fields(("username","password"));
$mech->field("username",$username);
$mech->field("password",$keyword);
 
print "Loggin...\n" if($deb);
 
$mech->submit_form();
 
$dest= $mech->response->content;
 
if($mech->response->header("Content-Encoding") eq "gzip")
{
        $dest = Compress::Zlib::memGunzip($dest);
        $mech->update_html($dest);
}
 
$mech->get("http://wwwl.way2sms.com//jsp/InstantSMS.jsp?val=0");
$dest= $mech->response->content;
if($mech->response->header("Content-Encoding") eq "gzip")
{
        $dest = Compress::Zlib::memGunzip($dest);
        $mech->update_html($dest);
}
 
print "Sending ... \n" if($deb);
 
$mech->form_with_fields(("MobNo","textArea"));
$mech->field("MobNo",$mobile);
$mech->field("textArea",$text);
$mech->submit_form();
 
if($mech->success())
{
print "Done \n" if($deb);
}
else
{
print "Failed \n" if($deb);
exit;
}
 
$dest =  $mech->response->content;
if($mech->response->header("Content-Encoding") eq "gzip")
{
        $dest = Compress::Zlib::memGunzip($dest);
		#print $dest if($deb);
}
 
if($dest =~ m/successfully/sig)
{
  print "Message sent successfully" if($deb);
}
 
exit;
#EOF

Usage

./sms.pl mobile number "message"

Example:
./sms.pl 9000012345 "Hey there does this work?"

Happy SMSing.

Warning

This script is not affiliated or has anything to do with Way2Sms.com. This piece of code is provided AS IS without any warranty. Usage of this script is solely upto you. WAY2SMS will not be happy about you using this script skipping their ads.

Enjoy SMSing...
Smiling


Similar Posts




Comments

Thanks a lot for keeping this page updated

Thanks a lot for keeping this page updated

Thanks a lot for keeping this page updated

Thanks a lot for keeping this page updated along with changes in way2sms.com

Hey, I am getting this error

Hey, I am getting this error when i try to send a messge
There is no form with the requested fields at ./sms.pl line 65
Can't call method "value" on an undefined value at /usr/share/perl5/vendor_perl/WWW/Mechanize.pm line 1348.

I think it was a network

I think it was a network problem, it works fine now..

Not receiving sms

Hi,

I tried to run above code from the linux machine. I got below output.

18
Fetching...
Loggin...
Sending ...
Done
Message sent successfully

But i didnt receive the message to my mobile. I would appreciate your help.

DK.

Filled in username and password ?

Hi
The script is updated now.
Please check if you have filled in your username and password also.

Thanks.

working fine

Thank you. With the updated script it is working fine,

DK

Mechanize Version?

What version of Mechanize are you runnning ?

Getting an Error while running the above code

Hi,
I'm getting the following Error while running the program.

"perl: relocation error: /user/kumark/perl/perl_modules/lib64/perl5/site_perl/5.8.0/auto/HTML/Parser/Parser.so: undefined symbol: Perl_Tstack_sp_ptr"

Can you please help me?.

Post new comment

The content of this field is kept private and will not be shown publicly.