Last active
December 15, 2015 13:09
-
-
Save jptoto/5265126 to your computer and use it in GitHub Desktop.
Postmark PHP Inbound Example
This file contains 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 | |
// Uses https://github.com/jjaffeux/postmark-inbound-php | |
require_once 'lib/Postmark/Autoloader.php'; | |
\Postmark\Autoloader::register(); | |
$inbound = new \Postmark\Inbound(file_get_contents('php://input')); | |
$filename = 'test.txt'; | |
$somecontent = $inbound->FromEmail(); | |
if (is_writable($filename)) { | |
if (!$handle = fopen($filename, 'a')) { | |
echo "Cannot open file ($filename)"; | |
exit; | |
} | |
// Write $somecontent to our opened file. | |
if (fwrite($handle, $somecontent) === FALSE) { | |
echo "Cannot write to file ($filename)"; | |
exit; | |
} | |
echo "Success, wrote ($somecontent) to file ($filename)"; | |
fclose($handle); | |
} else { | |
echo "The file $filename is not writable"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment