How to create your own SMS service website?

Ever wonder creating your own SMS service like a website, where a user can simply enter the sender number and send SMS to anyone they want.

What do you require?

  • Hosting/Server
  • Account on MSG91

MSG91 and other services provide a simple API which we could use in our custom code and start using our SMS service. This time we’re going to use There are more like etc.

For sending SMS using any language, you’d need an SMS gateway. Most of the SMS providers these days provide an API. For the below PHP snippet, I am using MSG91 as SMS gateway.


function send_sms($mobile,$msg)
	$authKey = "XXXXXXXXXXX";
	$date = strftime("%Y-%m-%d %H:%M:%S");
//Multiple mobiles numbers separated by comma
	$mobileNumber = $mobile;

//Sender ID,While using route4 sender id should be 6 characters long.
	$senderId = "IKOONK";

//Your message to send, Add URL encoding here.
	$message = urlencode($msg);

//Define route 
	$route = "template";
//Prepare you post parameters
	$postData = array(
    'authkey' => $authKey,
    'mobiles' => $mobileNumber,
    'message' => $message,
    'sender' => $senderId,
    'route' => $route


// init the resource
	$ch = curl_init();
	curl_setopt_array($ch, array(
    CURLOPT_URL => $url,
    CURLOPT_POST => true,

//Ignore SSL certificate verification
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

//get response
	$output = curl_exec($ch);
	//Print error if any
    	echo 'error:' . curl_error($ch);



You’d see that I have highlighted two lines. On the first highlighted line you need to enter your passkey and on the second you need to enter your senderID. While entering mobile number you need to specify the country code (For example, USA’s country code is 1. India’s country code is 91).


$message = "Hello World";
$mobile = "1234567890";


Leave a Reply

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

Back to top button