Search code examples
phpjoomlasms

How to Add SMS Feature to a Website?On admin Side


I designed a School Website. In that I want to add SMS sending feature(Bulk and Individual) on admin side so that all parents can receive events which are going on school, and also if a student is absent that should be informed to the particular parents phone via SMS.

I designed this Feature. But I want to know various Hosting Services all over India, including Pricing.

Here I want to Add Sender Name like LM-xxxx or DA-xxxx etc.. if there is a Yearly or Unlimited Validity plans Let me Know..

Please Suggest me. I have done the project in PHP(Joomla)


Solution

  • For that you have to get GSM device to send SMS through a serial port (usb). You can use a generic GSM module accesible using USB/Serial Cable, or a GSM Phone with a USB/Serial connector supported by your hardware.

    SMS gateway device

    1.Open the SMS gateway device and put the SMS card inside.

    2.Plug to network in the "power" input, plug the USB cable in the SMS Gateway device and connect the other end to the server using a standard USB port.

    3.When you connect the device to the server, wait a few seconds and run dmesg command from the command line.You should see something like this screenshot.

    This means device has been recognized by the kernel and it's ready to accept commands on a device, like /dev/ttyACM0. If you're here, the hardware setup is done. If not, please review all steps and be sure that:

    • Device is connected and led is blinking in a green color.
    • Device is connected to the USB port, both sides of wire, one side to the SMS device, and other side to the server host.
    • Device has a SIM card inside, and it's placed properly.

    Configure SMSTools to Use the New Device

    4.Device is managed by a software package called SMSTools. You can install smstools using the package provided by your Linux Distribution if you use linux.

    $ sudo apt-get install smstools 
    

    5.Go to base configuration file,

    vim /etc/smsd.conf
    

    6.Edit this file as

    devices = GSM1
    logfile = /var/log/smsd.log
    loglevel = 10
    
    [GSM1]
    device = /dev/ttyACM0
    incoming = no
    pin = 9999
    

    Use the PIN assigned to your SIM. Example,for me PIN is "9999".

    7.Then, start manually smstools.

    /usr/bin/smstools start
    

    8.Create a file in the server.ex:- send_sms_test.php and add this.

    <?php
    
    $to=$_GET['to'];
    $message=$_GET['msg'];
    
    #send sms for multiple users
    $to2=array_map('trim',explode(",",$to));
    
    foreach($to2 as $key=>$value){
       $file_name="xxx"; //add a file name u like
    
       $file = fopen("/var/spool/sms/outgoing/$file_name", "w+");
       fwrite($file,"\n");
       fwrite($file,"To: $to2[$key]");
       fwrite($file,"\n");
       fwrite($file,$message);
       fwrite($file,"\n");
       fwrite($file,"===============");
       fwrite($file,"\n");
       fwrite($file,"HI this is test sms alert");
       if($file==false)
            die("unable to create file");
       fclose($file);
    
       } // foreach end
    ?>
    

    9.By using API send data through URL.ex;-

    http://your.host.server.com/send_sms_test.php?to=0123456789,0987654321&msg=tst_for_check_multiple_sms
    

    (you can add multiple telephone numbers by comma "," separated)

    Or if you want to create this url in your script, use CURL ex:-

    curl "http://your.host.server.com/send_sms_test.php?to=0123456789,0987654321&msg=tst_for_check_multiple_sms"
    

    If you want to check that sms is sent,check on smsd.log file,

    cat /var/log/smsd.log