Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send SMS from Linux programmatically

Tags:

sms

gsm

I want to send SMS ideally using PHP in a Linux Environment. I have a GSM modem which I want to use to send SMS. Can anybody please tell me an easy way to send SMS from Linux using a USB GSM modem?

Thank you

like image 780
Emmanouil Avatar asked Oct 21 '25 03:10

Emmanouil


1 Answers

Your GSM modem will almost certainly support AT commands - you can see some history of AT, or Hayes, commands here: https://en.wikipedia.org/wiki/Hayes_command_set

The commands supported can vary from device to device but the simplest command sequence to send an SMS message is fairly standard - an example, showing the communication over the serial port, is:

AT+CMGF=1.  [you send this]
OK          [Modem responds]
AT+CMGS="+31628870634".   [you send this]
> Yourtextmessage.→.    [Modem responds with > and you send text followed by return at end]
+CMGS: 198  [Modem responds after a few moments when message is sent]

You should be able to find many more examples with a quick search including using PHP - e.g. (at the time of writing): https://gonzalo123.com/2011/03/21/howto-sendread-smss-using-a-gsm-modem-at-commands-and-php/

Its worth being aware that different modems may work differently - you will need to experiment to ensure you have a relabel solution.

like image 98
Mick Avatar answered Oct 26 '25 20:10

Mick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!