Send Receive Free SMS PHP

In this short tutorial we are going to learn about SMS functionality in our Send Receive Free SMS PHP project. SMS functionality is very common in every project these days but most cellular companies give a service very costly, due to high cost most student can not afford for learning projects. We have found a cost zero method for it. We know that everyone has smart device, we can use it for sending or receiving free sms in our php project. in this post we are going to learn all.

Before start to write code, let’s talk about prerequisites

  • Android mobile device (on this device you need android app installed)
  • GSM modem (SMS) app (we can find this app on playstore check further details here)
  • Laptop with php and mysql installed

There two sections first for sending and second or receiving so let’s start

Sending FREE SMS

For sending SMS from your project you need to create URL with required parameters.


Before starting to write code, you must change IP address and port in above URL and then put in any browser address bar and hit network call. You will receive sms on given number.

For sending sms from your project make you sure for some points.

  • Open GSM Android (SMS) app and start it.
  • Check IP with port number in your app.
  • Update IP address in your program


		<title>Sending SMS</title>

<h3>Sending SMS</h3>

<form method='GET' action='sendSMS.php'>
				Phone <input type='phone' name = 'phone' autocomplete='off'> 
				Message <input type='message' name='message'>
				<input type='submit' value='Send'/>


<?php try{ $message = isset($_GET['message']) ? $_GET['message'] : null; $phoneNumber = isset($_GET['phone']) ? $_GET['phone'] : null; if($message !=null && $phoneNumber !=null){ $url = "".$phoneNumber."&message=".urlencode($message); $curl = curl_init($url); curl_setopt($curl,CURLOPT_RETURNTRANSFER, true); $curl_response = curl_exec($curl); if($curl_response === false){ $info = curl_getinfo($curl); curl_close($curl); die('Error occurred'.var_export($info)); } curl_close($curl); $response = json_decode($curl_response); if($response->status == 200){
			echo 'Message has been sent';
			'Technical Problem';

}catch(Exception $ex){
	echo "Exception: ".$ex;

Receiving FREE SMS

For receiving free sms you must install GSM modem application, In that app you must add your url where you want to receive sms with given parameters. You must expose your own URL where you want to get sms text with phone number. In this tutorial we will save sms text and phone number in database (MySQL). GSM modem (SMS) hits on URL with following information GET method with message and phoneNumber parameters. For example http://…./receiveSMS.php?message=message&phoneNumber=123456789

Before testing GSM modem app for receiving SMS you must check these points.


  • Is your URL working fine with following request information, Method type GET with given parameters message and phoneNumber?
  • Have you entered your URL in app GET SMS at URL and check box is switched on?


<?php $servername = 'localhost'; $username = 'root'; $password = '1234'; $dbname = 'test'; $message = isset($_GET['message']) ? $_GET['message'] : null; $phoneNumber = isset($_GET['phoneNumber']) ? $_GET['phoneNumber'] : null ; $conn = new mysqli($servername, $username, $password, $dbname); if($conn->connect_error){
			die('Connection failed'.$conn->connect_error);

			$sql = "INSERT INTO inbox (phone_number, message) 
			Values ('".$phoneNumber."', '".$message."')";

			if($conn->query($sql) === TRUE){
				echo "New record created successfully";
				echo "Error: ".$sql. "
			$sql = "SELECT * FROM inbox";
			$result = $conn->query($sql);

				echo "
<table border=1>

				foreach($result as $row){
					echo "

				echo "</table>

				echo "Error: ".$sql. "




  1. I got on error in sending sms:
    array (
    ‘url’ => ‘’,
    ‘content_type’ => NULL,
    ‘http_code’ => 0,
    ‘header_size’ => 0,
    ‘request_size’ => 0,
    ‘filetime’ => -1,
    ‘ssl_verify_result’ => 0,
    ‘redirect_count’ => 0,
    ‘total_time’ => 2.207983,
    ‘namelookup_time’ => 0.001995,
    ‘connect_time’ => 0.0,
    ‘pretransfer_time’ => 0.0,
    ‘size_upload’ => 0.0,
    ‘size_download’ => 0.0,
    ‘speed_download’ => 0.0,
    ‘speed_upload’ => 0.0,
    ‘download_content_length’ => -1.0,
    ‘upload_content_length’ => -1.0,
    ‘starttransfer_time’ => 0.0,
    ‘redirect_time’ => 0.0,
    ‘redirect_url’ => ”,
    ‘primary_ip’ => ”,
    ‘certinfo’ =>
    array (
    ‘primary_port’ => 0,
    ‘local_ip’ => ”,
    ‘local_port’ => 0,
    ‘http_version’ => 0,
    ‘protocol’ => 0,
    ‘ssl_verifyresult’ => 0,
    ‘scheme’ => ”,
    ‘appconnect_time_us’ => 0,
    ‘connect_time_us’ => 0,
    ‘namelookup_time_us’ => 1995,
    ‘pretransfer_time_us’ => 0,
    ‘redirect_time_us’ => 0,
    ‘starttransfer_time_us’ => 0,
    ‘total_time_us’ => 2207983,
    )Error occurred

    1. When I get incoming SMS, the application show Erro occurred, and I see any message in my database.

  2. good day. i have tested your gsm modem app. it works great. i have a question. can you make also a video for VB.NET on how to recieved text message? or a tutorial for recieving msg using thank you …

Leave a Reply

Your email address will not be published. Required fields are marked *