Send Text Messages via PHP (by:

Text Message

Kids these days, I tell ya.  All they care about is the technology.  The video games.  The bottled water.  Oh, and the texting, always the texting.  Back in my day, all we had was…OK, I had all of these things too.  But I still don’t get the volume of texts that I hear my younger female cousins send.  Thousands and thousands of them each month.  WTF are all of these texts for?  Here’s a thought:

omg did you hear?

no wut

omg i can’t believe you didn’t hear

lol tell me!

jenny and mark were holding hands

omfg does john no?

ok i made it up, ur so lame

Riveting.  Jokes aside, text messaging can be an extremely useful way to get out of calling that person you hate calling communicate quickly and efficiently.  Many websites are now offering text message notifications instead of email notifications, which can be nice in the case of time-sensitive information.  After a bit of research, I found out how easy it was so send text messages using PHP, so that I can integrate text messaging into my apps!  Let me show you how!

The Methodology

Unbeknownst to me, sending text messages can be as easy as sendmail, because you can send your text to an email address and it will be delivered.  There are two pieces of information you must know:  the phone number and the carrier’s text message email domain.  Needing to know the recipient’s carrier is not ideal, but necessary.  Luckily Kevin Jensen has compiled a list of carriers and domains:

Phone companies have internal lookups for phone carriers but developers like you and I don’t get access to them, so knowing the carrier is  a must.  To send a text message, you email {phoneNumber}@{carrierDomain}.


PHP’s provided method for sending emails is the mail function.  Its usage is quite simple:

bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

Using the mail function and the text message email format, sending a text message is as easy as:

// Call Jenny
mail("", "", "Your packaged has arrived!", "From: David Walsh <>rn");

Note that no subject line is provided, and more importantly, a FROM header is within the last parameter so that the recipient knows where the text message has been sent from.

Who knew it was that easy?  I always assumed text messaging had its own protocol and all that magic.  Apparently not!  Spend a few minutes playing around with text messaging yourself;  it’s one of those things that’s both neat to do and useful!

Send Text Messages via PHP is a post from: David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.

original post:

via ifttt


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )


Conectando a %s

A %d blogueros les gusta esto: