public function getFieldValue($format = HeaderInterface::FORMAT_RAW) { $emails = []; $encoding = $this->getEncoding(); foreach ($this->getAddressList() as $address) { $email = $address->getEmail(); $name = $address->getName(); if (empty($name)) { $emails[] = $email; continue; } if (false !== strstr($name, ',')) { $name = sprintf('"%s"', $name); } if ($format === HeaderInterface::FORMAT_ENCODED && 'ASCII' !== $encoding) { $name = HeaderWrap::mimeEncodeValue($name, $encoding); } $emails[] = sprintf('%s <%s>', $name, $email); } // Ensure the values are valid before sending them. if ($format !== HeaderInterface::FORMAT_RAW) { foreach ($emails as $email) { HeaderValue::assertValid($email); } } return implode(',' . Headers::FOLDING, $emails); }
/** * @group ZF2-359 */ public function testMimeEncoding() { $string = 'Umlauts: ä'; $expected = '=?UTF-8?Q?Umlauts:=20=C3=A4?='; $test = HeaderWrap::mimeEncodeValue($string, 'UTF-8', 78); $this->assertEquals($expected, $test); $this->assertEquals($string, iconv_mime_decode($test, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8')); }
/** * Get the header value * * @return string */ public function getFieldValue() { $encoding = $this->getEncoding(); if ($encoding == 'ASCII') { return HeaderWrap::wrap($this->subject, $this); } return HeaderWrap::mimeEncodeValue($this->subject, $encoding, true); }
public function getFieldValue($format = HeaderInterface::FORMAT_RAW) { if (!$this->address instanceof Mail\Address\AddressInterface) { return ''; } $email = sprintf('<%s>', $this->address->getEmail()); $name = $this->address->getName(); if (!empty($name)) { $encoding = $this->getEncoding(); if ($format == HeaderInterface::FORMAT_ENCODED && 'ASCII' !== $encoding) { $name = HeaderWrap::mimeEncodeValue($name, $encoding); } $email = sprintf('%s %s', $name, $email); } return $email; }
public function getFieldValue($format = HeaderInterface::FORMAT_RAW) { $emails = array(); $encoding = $this->getEncoding(); foreach ($this->getAddressList() as $address) { $email = $address->getEmail(); $name = $address->getName(); if (empty($name)) { $emails[] = $email; } else { if (false !== strstr($name, ',')) { $name = sprintf('"%s"', $name); } if ($format == HeaderInterface::FORMAT_ENCODED && 'ASCII' !== $encoding) { $name = HeaderWrap::mimeEncodeValue($name, $encoding); } $emails[] = sprintf('%s <%s>', $name, $email); } } return implode(',' . Headers::FOLDING, $emails); }
/** * Get field value of this header * * @return string */ public function getFieldValue() { $emails = array(); $encoding = $this->getEncoding(); foreach ($this->getAddressList() as $address) { $email = $address->getEmail(); $name = $address->getName(); if (empty($name)) { $emails[] = $email; } else { if (false !== strstr($name, ',')) { $name = sprintf('"%s"', $name); } if ('ASCII' !== $encoding) { $name = HeaderWrap::mimeEncodeValue($name, $encoding, false); } $emails[] = sprintf('%s <%s>', $name, $email); } } $string = implode(",\r\n ", $emails); return $string; }
/** * Get header value * * @return string */ public function getFieldValue() { if (!$this->address instanceof AddressDescription) { return ''; } $email = sprintf('<%s>', $this->address->getEmail()); $name = $this->address->getName(); if (!empty($name)) { $encoding = $this->getEncoding(); if ('ASCII' !== $encoding) { $name = HeaderWrap::mimeEncodeValue($name, $encoding, false); } $email = sprintf('%s %s', $name, $email); } return $email; }
public function getFieldValue($format = HeaderInterface::FORMAT_RAW) { $emails = []; $encoding = $this->getEncoding(); foreach ($this->getAddressList() as $address) { $email = $address->getEmail(); $name = $address->getName(); if (!empty($name) && false !== strstr($name, ',')) { $name = sprintf('"%s"', $name); } if ($format === HeaderInterface::FORMAT_ENCODED && 'ASCII' !== $encoding) { if (!empty($name)) { $name = HeaderWrap::mimeEncodeValue($name, $encoding); } if (preg_match('/^(.+)@([^@]+)$/', $email, $matches)) { $localPart = $matches[1]; $hostname = $this->idnToAscii($matches[2]); $email = sprintf('%s@%s', $localPart, $hostname); } } if (empty($name)) { $emails[] = $email; } else { $emails[] = sprintf('%s <%s>', $name, $email); } } // Ensure the values are valid before sending them. if ($format !== HeaderInterface::FORMAT_RAW) { foreach ($emails as $email) { HeaderValue::assertValid($email); } } return implode(',' . Headers::FOLDING, $emails); }