Created
July 22, 2011 22:48
-
-
Save aaronpk/1100613 to your computer and use it in GitHub Desktop.
Email-to-SMS gateway
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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