Grow your CSS skills. Land your dream job.

Last updated on:

Send a Text Message

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. 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. 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. 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

Leave a Comment

Posting Code

  • Use Markdown, and it will escape the code for you, like `<div class="cool">`.
  • Use triple-backticks for blocks of code.
      <h1>multi-line block of code</h1>
      <span>be cool yo.</span>
  • Otherwise, escape your code, like <code>&lt;div class="cool"&gt;</code>. Markdown is just easier though.

Current ye@r *

*May or may not contain any actual "CSS" or "Tricks".