The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Send a Text Message

Last updated on:

You'll need a TextMagic account and to download their PHP helper which they provide after signing up.

// Include the TextMagic PHP lib

// Set the username and password information
$username = 'myusername';
$password = 'mypassword';

// Create a new instance of TM
$router = new TextMagicAPI(array(
	'username' => $username,
	'password' => $password

// Send a text message to '999-123-4567'
$result = $router->send('Wake up!', array(9991234567), true);

// result:  Result is: Array ( [messages] => Array ( [19896128] => 9991234567 ) [sent_text] => Wake up! [parts_count] => 1 )

Reference URL


  1. Rishi Kulshreshtha
    Permalink to comment#

    Hi Chris, nice one. First of all thanks for such an informative post, but what if I’m using a framework for an instance CakePHP will this method work with it?

  2. Will Vincent
    Permalink to comment#

    Rishi: The ‘correct’ way to do this with something like CakePHP or Zend would be to set up the TextMagic API as a third party library. But even just including it as Chris has demonstrated here would work, yes.

    Framework or not, at the end of the day it’s still PHP. ;)

  3. mymahesh11
    Permalink to comment#

    can i get the actual / full code of the send text message please…

  4. Jerbs
    Permalink to comment#

    All of your stuff is very impressive to say the least.. for texting you can also use MailUtils and SSMTP for free.

    echo “AuthUser=$AuthUser” >> /etc/ssmtp/ssmtp.conf
    echo “AuthPass=$AuthPass” >> /etc/ssmtp/ssmtp.conf
    echo “FromLineOverride=YES” >> /etc/ssmtp/ssmtp.conf
    echo “” >> /etc/ssmtp/ssmtp.conf
    echo “useSTARTTLS=YES” >> /etc/ssmtp/ssmtp.conf

    echo $message | mail -s “$SUBJECT” $NUMBER

  5. Jesse
    Permalink to comment#

    This is awesome, we’ve used to capture phone numbers and then use their platform to send them out.

Leave a Comment

Posting Code

We highly encourage you to post problematic HTML/CSS/JavaScript over on CodePen and include the link in your post. It's much easier to see, understand, and help with when you do that.

Markdown is supported, so you can write inline code like `<div>this</div>` or multiline blocks of code in in triple backtick fences like this:

  function example() {
    element.innerHTML = "<div>code</div>";

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed