Skip to content

Instantly share code, notes, and snippets.

@jptoto
Last active December 15, 2015 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jptoto/5265126 to your computer and use it in GitHub Desktop.
Save jptoto/5265126 to your computer and use it in GitHub Desktop.
Postmark PHP Inbound Example
<?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