Sending Text Messages in PHP

Recently I’ve had to implement an alert system in PHP were the alerts are sent via a text message. The concept is very simple – use an email to SMS gateway. Essentially, you send an email to a phone companies gateway server, that server then relays the email to the phone number specified via a SMS. Since PHP has the ability to send emails, the whole process is quite easy.

1. First you need to acquire a list of SMS gateways you are going to support. For an extensive list, check out Wikipedias List of SMS Gateways. For this tutorial, I will only be using AT&T Wireless (number@txt.att.net) and Verison (number@vtext.com).

2. Create a simple HTML form.
[code lang="html"]



[/code]

3. Add the necessary PHP code to send the email
[code lang="PHP"]



if(!empty($_POST['number'])) {
mail($_POST['number'] . $_POST['provider'], $_POST['subject'], $_POST['message']);
}
?>


[/code]

You will want to do some better error checking and validation, but thats it!

Related posts:

  1. Email Obfuscator [code lang="Javascript"] [/code]...
  2. HTML5 Input Lets be honest, HTML5 is the new buzz word. Every blog, tutorial, tweet, article, or post I read contains some...
  3. Using PHP and GD to add border to text [code lang="PHP"][/code]...
  4. imagettftext only displays yellow text Lately I have been doing some work with the PHP GD library. I wanted to put text on an image...
  5. Getting to know GD Create dynamic userbars with GD Introduction: Have you ever been on aim and received a message from one of your...

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.


3 Responses to “Sending Text Messages in PHP”

  1. please check email

    please take a look at your email and leave a message

    Reply |

    • John

      What email address should I be checking?

      Reply |

  2. Pixel2life.com

    Thank you so much for submitting your tutorial to Pixel2life, your submission has been accepted :) I look forward to more tutorials from your site in the future!

    Reply |