/** * Retrieves Message Reference * * @param \Zend\Mail\Headers $headers * @return string|null */ protected function processMessageReference($headers) { $messageReference = null; if ($headers->get('references')) { preg_match('/<([^<]+)>/', $headers->get('references')->getFieldValue(), $matches); $messageReference = $matches[1]; } return $messageReference; }
public function testHeadersCanRemoveHeader() { $headers = new Headers(); $headers->addHeaders(array('Foo' => 'bar', 'Baz' => 'baz')); $header = $headers->get('foo'); $this->assertEquals(2, $headers->count()); $headers->removeHeader($header); $this->assertEquals(1, $headers->count()); $this->assertFalse($headers->get('foo')); }
/** * Retrieves Message Subject * * @param \Zend\Mail\Headers $headers * @return string|null */ private function processSubject($headers) { $messageSubject = $headers->get('subject') ? $headers->get('subject')->getFieldValue() : null; return $messageSubject; }
/** * Gets an email importance * * @param Headers $headers * * @return integer */ protected function getImportance(Headers $headers) { $importance = $headers->get('Importance'); if ($importance instanceof HeaderInterface) { switch (strtolower($importance->getFieldValue())) { case 'high': return 1; case 'low': return -1; default: return 0; } } $labels = $headers->get('X-GM-LABELS'); if ($labels instanceof HeaderInterface) { if ($labels->getFieldValue() === '\\\\Important') { return 1; } } elseif ($labels instanceof \ArrayIterator) { foreach ($labels as $label) { if ($label instanceof HeaderInterface && $label->getFieldValue() === '\\\\Important') { return 1; } } } return 0; }
public function testRemoveHeaderWithInstanceWillRemoveThatInstance() { $headers = new Mail\Headers(); $headers->addHeaders(array(array('Foo' => 'foo'), array('Foo' => 'bar'), 'Baz' => 'baz')); $header = $headers->get('foo')->current(); $this->assertEquals(3, $headers->count()); $headers->removeHeader($header); $this->assertEquals(2, $headers->count()); $this->assertTrue($headers->has('foo')); $this->assertNotSame($header, $headers->get('foo')); }