views:

285

answers:

5

Is there any PHP script to send SMS. I wan to send activation code on user's mobile phone.

+1  A: 

You will need a SMS gateway. A lot of them will send messages sent to an email on via SMS, so you can just use the mail() function.

This looks like a good bunch of links.

alex
Woo! Another anonymous downvoter! So tell me what is wrong so we can discuss?
alex
+1  A: 

read this its useful.

tazphoenix
+1  A: 

You need to have a connection of some sort (for example a cell phone or a GSM modem) from your server to the cell network to directly send text messages.

But there are a lot of alternatives if you're willing to go through a third party service. Look at these question for some tips:

I bet some of the services listed in the answers of those questions also have example PHP-scripts available.

alleus
A: 

Depending on your cellular network provider, the easiest option would be using a WWW or email SMS gateway - if they provide any. No two providers have the same API, you'll have to RTFM and adapt.

Otherwise, you're stuck with a GSM modem - grab one with a well docummented AT command set. You communicate over a serial port (either plain RS232 or emulated over USB line), using extended AT command set. You'll have to converse with the modem - pass it the PIN, (send AT+CPIN="0000" or whatever), then send the SMS with some similar command.

Definitely look for docs before purchase of the modem, as there are many "consumer" modems that require proprietary software to use and don't export any API for SMS and the likes. I'm pretty sure most Wavecom and Sagem modems are "open", OTOH avoid Huaweii with "zero-installation drivers" like fire - they identify as CD-Drive with autoplaying disk inside, and the autoplay installs driver that sends special command to switch the modem into "modem" mode from "CD drive" mode... takes quite a bit of work to do it yourself.

There is a PHP module to use serial port, just configure the modem and point your script at the right port ( /dev/ttyUSB0, COM1 etc) but I think you'll have to handle the AT commands set layer yourself.

SF.
A: 

Here's an SMS verification example in PHP using Twilio (full disclosure, I work for Twilio).

John Sheehan