以编程方式从 Linux 发送短信

Send SMS from Linux programmatically

我想在 Linux 环境中使用 PHP 理想地发送短信。我有一个 GSM 调制解调器,我想用它来发送 SMS。 谁能告诉我使用 USB GSM 调制解调器从 Linux 发送短信的简单方法?

谢谢

您的 GSM 调制解调器几乎肯定会支持 AT 命令 - 您可以在此处查看 AT 或 Hayes 命令的一些历史记录:https://en.wikipedia.org/wiki/Hayes_command_set

支持的命令因设备而异,但发送 SMS 消息的最简单命令序列是相当标准的 - 例如,显示串行端口上的通信是:

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]

您应该能够通过快速搜索找到更多示例,包括使用 PHP - 例如(在撰写本文时):https://gonzalo123.com/2011/03/21/howto-sendread-smss-using-a-gsm-modem-at-commands-and-php/

值得注意的是,不同的调制解调器可能工作方式不同 - 您需要进行试验以确保您有重新标记的解决方案。