Location: PHPKode > scripts > VinSMSIndia > vinSMSIndia.class.php
<?php
/**
 * Send SMS to Indian Mobile user for free...
 *
 *  Usage:
 *   $sms = new vinSMSIndia;
  	 $returnArr = $sms->sendSMS($_POST["mobile"],$_POST["subject"],$_POST["message"]);

	returns 
		array(
					"mobile" => 
					"state" => 
					"service" => 
					"time" => time()
				);

 *
 *
 * Vinay Yadav (vinayRas)
 * hide@address.com
 * http://www.vinayras.com/
 *
 * You can test it online at
 * http://www.vinayras.com/sms.php
 *
 */
class vinSMSIndia {

  /**
  * Service providers list
  */
  var $SMSArray = array(
   		"9849"=>array("state"=>"Andhra Pradesh",
			      "service"=>"Airtel",
			      "email"=>"airtelap.com"
			      ),
		"9848" => array("state"=>"Andhra Pradesh",
			      "service"=>"Idea Cellular",
			      "email"=>"ideacellular.net"
			      ),
		"9840" => array("state"=>"Chennai",
			      "service"=>"Skycell / Airtel",
			      "email"=>"airtelchennai.com"
			      ),
		"9841" => array("state"=>"Chennai",
			      "service"=>"RPG Cellular",
			      "email"=>"rpgmail.net"
			      ),
		"9810" => array("state"=>"Delhi",
			      "service"=>"Airtel",
			      "email"=>"airtelmail.com"
			      ),
		"9811" => array("state"=>"Delhi",
			      "service"=>"Hutch",
			      "email"=>"delhi.hutch.co.in"
			      ),
			      
		"9824" => array("state"=>"Gujarat",
			      "service"=>"Idea Cellular",
			      "email"=>"ideacellular.net"
			      ),
		"9898" => array("state"=>"Gujarat",
			      "service"=>"Airtel",
			      "email"=>"airtelmail.com"
			      ),
		"9835" => array("state"=>"Gujarat",
			      "service"=>"Celforce / Fascel",
			      "email"=>"celforce.com"
			      ),
		"9890" => array("state"=>"Goa",
			      "service"=>"Airtel",
			      "email"=>"airtelmail.com"
			      ),
		"9823" => array("state"=>"Goa",
			      "service"=>"BPL Mobile",
			      "email"=>"bplmobile.com"
			      ),
		"9822" => array("state"=>"Goa",
			      "service"=>"Idea Cellular",
			      "email"=>"ideacellular.net"
			      ),
		"9896" => array("state"=>"Haryana",
			      "service"=>"Airtel",
			      "email"=>"airtelmail.com"
			      ),
		"9812" => array("state"=>"Haryana",
			      "service"=>"Escotel",
			      "email"=>"escotelmobile.com"
			      ),
		"9816" => array("state"=>"Himachal Pradesh",
			      "service"=>"Airtel",
			      "email"=>"airtelmail.com"
			      ),
		"9845" => array("state"=>"Karnataka",
			      "service"=>"Airtel",
			      "email"=>"airtelmail.com"
			      ),
		"9895" => array("state"=>"Kerala",
			      "service"=>"Airtel",
			      "email"=>"airtelmail.com"
			      ),
		"9847" => array("state"=>"Kerala",
			      "service"=>"Escotel",
			      "email"=>"escotelmobile.com"
			      ),
		"9846" => array("state"=>"Kerala",
			      "service"=>"BPL Mobile",
			      "email"=>"bplmobile.com"
			      ),
		"9831" => array("state"=>"Kolkata",
			      "service"=>"Airtel",
			      "email"=>"airtelkol.com"
			      ),
		"9893" => array("state"=>"Madhya Pradesh",
			      "service"=>"Airtel",
			      "email"=>"airtelmail.com"
			      ),
		"9890" => array("state"=>"Maharashtra",
			      "service"=>"Airtel",
			      "email"=>"airtelmail.com"
			      ),
		"9823" => array("state"=>"Maharashtra",
			      "service"=>"BPL Mobile",
			      "email"=>"bplmobile.com"
			      ),
		"9822" => array("state"=>"Maharashtra",
			      "service"=>"Idea Cellular",
			      "email"=>"ideacellular.net"
			      ),
		"9892" => array("state"=>"Mumbai",
			      "service"=>"Airtel",
			      "email"=>"airtelmail.com"
			      ),
		"9821" => array("state"=>"Mumbai",
			      "service"=>"BPL Mobile",
			      "email"=>"bplmobile.com"
			      ),
		"9815" => array("state"=>"Punjab",
			      "service"=>"Airtel",
			      "email"=>"airtelmail.com"
			      ),
		"9843" => array("state"=>"Pondicherry",
			      "service"=>"BPL Mobile",
			      "email"=>"bplmobile.com"
			      ),
		"9894" => array("state"=>"Tamil Nadu",
			      "service"=>"Airtel",
			      "email"=>"airteltn.com"
			      ),
		"9843" => array("state"=>"Tamil Nadu",
			      "service"=>"BPL Mobile",
			      "email"=>"bplmobile.com"
			      ),
		"9842" => array("state"=>"Tamil Nadu",
			      "service"=>"Aircel",
			      "email"=>"airsms.com"
			      ),
		"9837" => array("state"=>"Uttar Pradesh (West)",
			      "service"=>"Escotel",
			      "email"=>"escotelmobile.com"
			      )
  		    );	
	/**
	* Error message
	*/
	var $Error = "";

	/**
	* Headers 
	*/
	var $headers = "From: hide@address.com";

	/**
	* Constructor
	*/
	function vinSMSIndia() {
		// Dont ahve to do anything!!!! 
	}

	/**
	* Send SMS
	*/
	function sendSMS($mopbileNum,$subject,$message) {
		if(empty($mopbileNum)) {
			$this->Error = "Mobile number should be provided!";			
			return false;
		}

		$smsNum = substr($mopbileNum,0,4);	
		$sendArr = $this->SMSArray["$smsNum"];	

		if(!is_array($sendArr) || empty($sendArr["email"])) {
			$this->Error = "Support not avialable for this Service Provided";			
			return false;
		}

		/**
		* Send email at the said email - 
		* This will automatically be sent as email by the service provided
		*/
		mail("$mopbileNum@$sendArr[email]","",$message,$this->headers);

		/**
		* Return an array of information
		*/
		return array(
					"mobile" => $mopbileNum,
					"state" => $sendArr["state"], 
					"service" => $sendArr["service"],
					"time" => time()
					);
	}
}
	
Return current item: VinSMSIndia