Skip to content

Instantly share code, notes, and snippets.

@aaronpk
Created July 22, 2011 22:48
Show Gist options
  • Select an option

  • Save aaronpk/1100613 to your computer and use it in GitHub Desktop.

Select an option

Save aaronpk/1100613 to your computer and use it in GitHub Desktop.
Email-to-SMS gateway
<?php
require_once('php-mime-mail-parser/MimeMailParser.class.php');
require_once(dirname(__FILE__) . '/Regex.php');
require_once(dirname(__FILE__) . 'smsified.class.php');
// get the email from STDIN
$buffer = '';
while(!feof(STDIN))
$buffer .= fgets(STDIN);
$parser = new MimeMailParser();
// Load the email into the parser
$parser->setText($buffer);
$from = $parser->getHeader('from');
if($name=Regex_EmailRecipient::getName($from))
$from = $name;
$message = 'From ' . $from . ' "' . $parser->getHeader('subject') . '"';
// Send the SMS now using smsified.com
$sms = new SMSified($sms_username, $sms_password);
$sms->sendMessage($senderAddress, "14078971234", $message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment