Friday, March 20, 2009

A Hack: Web-based Texting to AT&T Phones

So, Michelle and I bought iPhones yesterday. While we're having fun with them, we did notice a problem: Our old phones were on Sprint, and Sprint provides a Web-based interface for sending text messages. AT&T seems to want you to log in to their system to send text messages. Since Michelle's work needs to text her regularly, that didn't seem to be a good solution.

Fortunately, AT&T does provide email-based texting (1234567890@txt.att.net). So, I taught myself some PHP, built a small Web interface to the PHP email function, and, voila, her work can now text to her. All in under an hour of time.

The script is appended. The HTML-based UI should be obvious. Comments are appreciated.
<?php
$phone = $_GET['phone'];
if (!$phone)
{
echo 'No phone number specified.';
exit(1);
}
$to = "$phone@txt.att.net";

$subject = $_GET['subject'];
$body = $_GET['body'];

if (!$body)
{
echo 'No body specified.';
exit (1);
}

$headers = "From: $to";

$mail_sent = @mail( $to, $subject, $body, $headers );
echo $mail_sent ? "Message sent" : "Message failed";
?>

No comments:

Post a Comment