Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsTo send an SMS from PHP through a GSM modem, PHP must open the modem’s AT-command serial port, select an SMS format, issue AT+CMGS, wait for the modem’s prompt, send the message, and finish with Ctrl+Z (ASCII 26). The exact port, serial settings, command syntax, and available SMS features depend on the modem, firmware, host operating system, and cellular service.
What you need before writing the PHP code
PHP is the host-side controller; it does not send an SMS by itself. It communicates with a cellular modem that exposes an AT-command interface over USB serial or UART. “GSM modem” is often used broadly: confirm that the specific device supports SMS AT commands and works with the radio technology, bands, and carrier service available in your country.
As an Amazon Associate I earn from qualifying purchases.
- A modem with a documented AT-command port and SMS support.
- A SIM and service that permit sending SMS, with the modem registered on a supported network.
- The correct device port, driver, and serial settings for the host computer. Some USB modems expose multiple interfaces; only one may accept AT commands.
- A PHP serial-port implementation that works with your operating system and installed PHP runtime. There is no single universal PHP serial API established for every platform, so check its maintenance and compatibility before choosing one.
Follow the modem manual for baud rate, flow control, line endings, timeouts, and echo settings. These details are device-specific; a serial connection that opens successfully does not necessarily mean you have selected the AT port.
Text mode or PDU mode?
| Mode | Command | What it means |
|---|---|---|
| Text mode | AT+CMGF=1 |
Sends a message as text when the modem supports this mode. It is the simpler choice for a basic walkthrough, but encoding and message-length behavior still depend on the device. |
| PDU mode | AT+CMGF=0 |
Sends a protocol data unit that the application must construct and encode correctly. Use it when you need its encoding or control capabilities and can implement the required PDU format. |
These are standardized SMS command-family options, but support and precise behavior must be checked in the target modem’s manual. For a basic text message, start with text mode if the modem supports it. The ETSI index for TS 27.005 lists the SMS command family; consult the applicable standard and device documentation for normative details.
#1 Best Overall
- ◇Introduction: USB to GSM is a four-frequency GSM/GPRS module, its stable performance, and can meet a variety of customer needs. Integrated USB to serial port chip, directly plug in the computer can be debugging. The operating frequency of SIM800C is GSM/GPRS 850/900/1800/1900mhz, which can be used worldwide. It can realize the transmission of voice, SMS messages, and data information with low power consumption, and can be suitable for various compact product design requirements.
- ◇ On-board original SIM800C GSM/GPRS module; On-board CH340T USB to serial port chip, simple driver installation and high compatibility; self-elastic SIM card slot design, can use 2G/3G/4G Micro SIM and Nano card;
- ◇The USB to GSM module will automatically start up and connect to the network when it is powered on. It does not need to control the startup with buttons, which saves the troublesome startup process;
- ◇Support SMS sending and receiving, provide management software; provide reference host computer source code (c#, vb) supporting materials and instructions for use; support GPRS data transmission under 2G network, which can be used in mobile meter reading and other occasions;
- ◇Support Bluetooth data transmission, IEEE802.15 bluetooth standard, 2.4GHz working frequency band; support adaptive baud rate; with working indicator, no network, no SIM card or when the SIM card is inserted backward, the LED light flashes quickly at 1-second intervals, normal Blinks once every 3 seconds when connected to the network.
Send a text message with AT commands
- Open the documented AT port. Identify the modem’s correct USB serial or UART interface in the operating system and open it using a compatible PHP serial implementation. Use the serial settings specified by the manufacturer.
- Probe the modem. Send
ATusing the documented line termination, then read the response. Continue only after you receive a recognizable reply. If the modem echoes commands, account for that when parsing responses. - Select text mode. Send
AT+CMGF=1and read the modem’s response. Do not assume the mode was selected if the modem reports an error. - Start the send operation. Send
AT+CMGS="+15551234567", replacing the example with the recipient number in the format expected by your modem and carrier. Follow your device manual for exact syntax. Wait for the message-entry prompt, commonly>, before sending the body. - Submit the message. Write the message body, then send Ctrl+Z, the single character with ASCII value 26. This signals the end of the message; do not substitute a newline for Ctrl+Z.
- Read the final result. Continue reading until the modem returns a complete result or your chosen timeout expires. Parse success and error responses rather than treating a successful PHP write as proof of success.
The command sequence is illustrative, not a drop-in PHP program: the serial-port API, write and read methods, line termination, and timeout handling differ across PHP environments. Keep the command exchange ordered and wait for each required response, especially the prompt between AT+CMGS and the message body. MikroTik’s RouterOS manual gives one product-specific example of the send commands, stating, “AT+CMGS and AT+CMGF commands are used.” That documentation is an implementation example, not PHP code or a universal description of modem behavior.
Read responses and distinguish acceptance from delivery
Check the modem’s response after each command. A successful port write only means that PHP handed bytes to the host interface. It does not prove that the modem accepted the command. Likewise, a message reference and final success response indicate the modem’s reported result, not necessarily that the recipient’s handset received the SMS. Error formats, extended SMS errors, and delivery-status features vary by modem and configuration.
Rank #2
- Industrial-Grade GSM Modem
- Based on Wavecom Q2303A Module
- USB Port Interface
- Control via AT Commands
- Support Dual Frequencies: GSM 900/1800MHz
OKor another documented success result: the modem accepted the command at that stage; continue with the next step in the sequence.ERRORor an extended error: stop, record the response, and consult the modem manual before retrying. The reason may be an unsupported command, invalid syntax, or an SMS or network problem.- No complete response before timeout: check the port, serial configuration, line termination, and whether another process is using the modem. Choose timeouts appropriate to the device and network rather than assuming every response is immediate.
Troubleshoot common failures
No response to AT
- Verify that the modem is powered and the cable, driver, and selected serial interface are correct.
- Check the manufacturer’s baud rate, flow-control requirements, and line termination.
- Close other software that may already own the port. A shared modem port needs coordinated, serialized access.
Garbled data or unexpected command echo
Match the modem’s serial settings and command termination, then account for echo behavior in your response parser. Echo and supported serial configuration options are implementation-specific; check the device manual.
No prompt after AT+CMGS
Read any response that precedes the missing prompt. Confirm that SMS mode was selected, the destination syntax is valid, the SIM is usable, and the modem supports SMS on that interface and network. Do not send the body until the modem signals that it is ready to accept it.
Rank #3
- 🏡【High-speed 4G LTE USB Modem Dongle】4g lte wifi modem router has super signal receiving capability and efficient data transmission. Our 4g usb sim card modem mobile wifi hotspot adopts IEEE 802.11b/g/n wireless transmission standard and has a wireless speed of up to 150Mbps, download speed 100Mbps, upload speed up to 50Mbps. Large coverage area, 10 meters long-distance transmission. The wireless internet router extendable is suitable for AT&T, T-Mobile, Mint Mobile. portable wifi 4g sim card wifi modem
- 🏡【Plug and Play】The 4g wifi modem usb router is driver-free and don't need to install software, power-connected via USB, you can provide a network to the computer, which makes it convenient to use. You can also connect your mobile phone to the usb cellular modem portable wifi for use. 4g lte dongle We recommend that you use the 4g usb modem for short distances indoors. usb fax modem modem router combo hotspot device portable wifi hotspot for travel
- 🏡【Small Portable 4G Dongle With Sim Card Slot】usb 4g lte modem You can take this 4g wifi router portable everywhere where you want, and adjust the angle of damping metal shaft according to your own usage habits and signal strength. The 4g lte wifi router can be able to connect with tablet ,laptop, notebook and various types of WiFi devices. WDINLY 4g lte usb modem dongle router is suitable for travel, outdoor working, business meeting and outdoor barbecue. If you want a PDF manual for using this 4g lte modem mobile hotspot, you can download it from the "Product guides and documents" section of the product detail page. 4g lte router with sim card slot
- 🏡【Compatible 4G Wifi Router Modem】The hotspot wifi portable for car can access to 10 devices. This 4g wifi router with sim card slot can be connected and used if there are wifi-enabled devices, such as mobile phones, smart robots, iPads, smart speakers, cameras, TVs, computers, etc. usb lte modem The USB WiFi modem device is widely compatible for Windows XP (SP3), Windows Vista (SP1), Windows7 or Windows8/10, and Macs with OS x v10.5.7, OS X Lion V10.7.3 or later. WiFi Standard: 802.11 b/g/n devices. 4g lte usb dongle unlocked
- 🏡【Why Choose This Mobile Hotspot Device】4g portable usb modem You can change or hide the internet password of your portable wifi hotspot no contract, you can build a wifi environment that won't be easily cracked by others. Its built-in antenna has multi-wide-angle coverage to accurately accept amplified signals. portable internet hotspot The signal of portable wifi for car can intelligently track the location of wireless terminals, such as mobile phones, computers, iPads, and TVs, enhance the unknown WiFi signal strength of each device.4g lte usb portable router
The modem reports success but the recipient gets nothing
Check the final modem result, network registration and signal, SMS service on the SIM or account, recipient-number format, and the service-centre address if the modem or carrier requires it. A modem’s success response alone is not confirmation of handset delivery.
Unicode or long messages behave differently
Character encoding, text-mode limits, segmentation, and concatenation support can differ between modems and firmware. Test the exact character set and message length on the target device. RouterOS documentation describes restrictions for that product’s implementation; those restrictions should not be assumed to apply to other modems.
Rank #4
- Plug and play: 4G mobile is plug and play, enjoy 4G internet, convenient USB power supply method, connect power device, insert SIM card, use SIM card data to surf the Internet anytime, anywhere.
- Multiple : router adopts multiple design, more secure, WPA/WPA2 encryption, effectively avoid internet squatting, support data control.
- Support Multiple Users: USB portable supports multiple terminals to access the Internet at the same time, and supports 10 devices, such as mobile phones,laptops, computers, smart TVs and other devices.
- USB Powered: Portable supports multiple 4G networks, sharing up to 10 users, powered by devices with USB ports, such as mobile phone chargers, car chargers, power banks, etc.
- High Speed Stable: 4G USB portable provides fast and stable high speed Internet access, high speed 4G internet, stable , feel the wonderful internet life, and fast Internet access.
Other SMS commands you may encounter
For a send-only integration, AT+CMGF and AT+CMGS are the main commands to understand. The wider SMS command family includes AT+CMGL for listing messages, AT+CMGR for reading, AT+CMGD for deleting, AT+CPMS for selecting message storage, AT+CNMI for configuring new-message indications, and AT+CSCA for the SMS service-centre address. Use these only when your application needs the corresponding behavior, and verify their syntax and support in the modem documentation.
Keep the modem connection reliable
Give one process at a time responsibility for the AT port, or add an explicit lock and queue if multiple parts of the application need it. AT commands and their replies form a stateful exchange: interleaved commands can make a response appear to belong to the wrong operation. Also log the command stage and modem response while avoiding unnecessary exposure of message content or phone numbers in application logs.
Quick Recap
Best Value
- Easy Connection: This 4G LTE router only needs to be inserted with SIM card to search and connect, automatically turn on high speed 4G.
- Up to 10 Users: This 4G router supports up to 10 users, suitable for phone, laptop, tablet, PC and TV, etc.
- High Safety: This mobile router with multiple adopts WPA/WPA2 encryption to provide security, support data control.
- Portable Size: This SIM dongle features in small and portable size can provide fast and stable .
- Plug and Play: This 4G USB modem can be powered by devices with USB port, such as phone charger, car charger and power bank.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




