Ejemplo n.º 1
0
 public function handle_post()
 {
     $input = file_get_contents('php://input');
     if (empty($input)) {
         header('X-Fail: No input', true, 400);
         echo 'No input found.';
         // intentionally not translated
         return;
     }
     file_put_contents('/tmp/postmark', $input);
     try {
         $inbound = new \Postmark\Inbound($input);
     } catch (\Postmark\InboundException $e) {
         header('X-Fail: Postmark problem', true, 400);
         echo $e->getMessage();
         return;
     }
     // The "Test" button sends an email from support@postmarkapp.com
     if ($inbound->FromEmail() === '*****@*****.**') {
         echo 'Hello tester!';
         // intentionally not translated
         return;
     }
     $reply = new Falcon_Reply();
     $reply->subject = $inbound->Subject();
     $reply->body = $inbound->TextBody();
     $to = $inbound->Recipients();
     list($reply->post, $reply->site, $reply->user, $reply->nonce) = Falcon_Reply::parse_to($to[0]->Email);
     $reply_id = $reply->insert();
     if ($reply_id === false) {
         header('X-Fail: No reply ID', true, 400);
         echo 'Reply could not be added?';
         // intentionally not translated
         // Log this?
     }
 }
Ejemplo n.º 2
0
<?php

require 'vendor/autoload.php';
// this file should be the target of the callback you set in your postmark account
$inbound = new \Postmark\Inbound(file_get_contents('../../fixtures/inbound.json'));
//$inbound = new \Postmark\Inbound(file_get_contents('php://input'));
echo $inbound->Subject();
echo $inbound->FromEmail();