protected function execute(InputInterface $input, OutputInterface $output) { $raw = ''; while ($line = fgets(STDIN)) { $raw .= $line; } $parser = new EmailParser($raw); $issue = new Support(); $issue->setFrom($parser->getRawFrom())->setTo($parser->getRawTo())->setCc($parser->getRawCc())->setSubject($parser->getSubject())->setBody($parser->getTextPart()); if (preg_match('/^support-(?:Lreply-)?([0-9]+)@/', $issue->getTo(), $matches)) { $this->processReply($issue, $matches[1], true, $output); } elseif (preg_match('/^support-(?:reply-)?([0-9]+)@/', $issue->getCc(), $matches)) { $this->processReply($issue, $matches[1], false, $output); } elseif (preg_match('/^support-bounces@/', $issue->getTo())) { $this->processBounce($parser->getRawFrom(), $parser->getRawTo(), $parser->getSubject(), $parser->getRawBody(), $output); } else { //support@ or websupport@ $this->processNew($issue, $output); } }
public function testbase64Email() { $txt = <<<EOT Date: Sun, 30 Nov 2014 03:31:55 -0800 From: testuser@gmail.com To: websupport@camdram.net Subject: Test email Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_BA30C081-D84C-4E2A-AB8C-105C9BB97412_"; charset=UTF-8 Content-Transfer-Encoding: 7bit --_BA30C081-D84C-4E2A-AB8C-105C9BB97412_ Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8" QmxhaCBibGFoIGJsYWgKClJlZ2FyZHMsIEpvaG4= --_BA30C081-D84C-4E2A-AB8C-105C9BB97412_-- EOT; $parser = new EmailParser($txt); $this->assertContains($this->msg, $parser->getTextPart()); }