Execute AT commands to send sms in php

Milind More picture Milind More · Apr 9, 2013 · Viewed 19k times · Source

I am trying to execute AT commands from PHP.

I tried exec() and shell_exec()

Please don't suggest third party SMS gateway my client doesn't want to disclose his private information and wants to send SMS from his own server.

I have a GSM modem attach to a serial port which I can access through "putty" like in fig putty screen 1

And I can enter AT commands to send SMS like in fig below. enter image description here

I want to run those AT commands through PHP.

Answer

user2377528 picture user2377528 · Dec 10, 2013

Hi I am sending sms using php class on windows 8 by this php code.

require "php_serial.class.php";
$serial = new phpSerial;
$serial->deviceSet("COM4");
$serial->confBaudRate(115200);

// Then we need to open it
$serial->deviceOpen();

// To write into
$serial->sendMessage("AT+CMGF=1\n\r"); 
$serial->sendMessage("AT+cmgs=\"+92234444444\"\n\r");
$serial->sendMessage("sms text\n\r");
$serial->sendMessage(chr(26));

//wait for modem to send message
sleep(7);
$read=$serial->readPort();
$serial->deviceClose();

PHP SERIAL class Link