public function handleIncomingMail($emailBuffer) { $pep = new PlancakeEmailParser($emailBuffer); $body = $pep->getBody(); if (empty($body) || !$body) { $body = $pep->getHtmlBody(); } $vcalendarStart = strpos($body, "BEGIN:VCALENDAR"); $vcalendarEnd = strpos($body, "END:VCALENDAR", $vcalendarStart); $vcalendarBody = substr($body, $vcalendarStart, $vcalendarEnd - $vcalendarStart); echo "subject: " . $pep->getSubject() . "\r\n"; echo "to:" . $pep->getTo()[0] . "\r\n"; echo "body: " . $body . "\r\n"; echo "vcalendarBody: " . $vcalendarBody . "\r\n"; $ical = new vCalendar($vcalendarBody); $this->handle_remote_attendee_reply($ical); }
<?php // run this as: // php run_tests.php require_once "../PlancakeEmailParser.php"; $emails = glob('./emails/*'); echo "\r\n\r\n\r\n"; foreach ($emails as $email) { echo "Email {$email} \r\n"; $emailParser = new PlancakeEmailParser(file_get_contents($email)); echo "subject: " . $emailParser->getSubject() . "\r\n"; echo "body: " . $emailParser->getBody() . "\r\n"; echo "\r\n\r\n\r\n"; }
<?php // run this as: // php run_tests.php function printBarrier() { echo "\r\n\r\n\r\n"; } function printnl($message) { echo "{$message}\r\n"; } require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . "PlancakeEmailParser.php"; $emails = glob(__DIR__ . DIRECTORY_SEPARATOR . "emails" . DIRECTORY_SEPARATOR . "*"); printBarrier(); foreach ($emails as $email) { printnl("Email {$email}"); $emailParser = new PlancakeEmailParser(file_get_contents($email)); printnl("subject: " . $emailParser->getSubject()); printnl("body: " . $emailParser->getBody()); printBarrier(); }