/** * Gets the attachment content * * @return Content */ public function getContent() { if ($this->part->getHeaders()->has('Content-Type')) { /** @var \Zend\Mail\Header\ContentType $contentTypeHeader */ $contentTypeHeader = $this->part->getHeader('Content-Type'); $contentType = $contentTypeHeader->getType(); $charset = $contentTypeHeader->getParameter('charset'); $encoding = $charset !== null ? $charset : 'ASCII'; } else { $contentType = 'text/plain'; $encoding = 'ASCII'; } if ($this->part->getHeaders()->has('Content-Transfer-Encoding')) { $contentTransferEncoding = $this->part->getHeader('Content-Transfer-Encoding')->getFieldValue(); } else { $contentTransferEncoding = 'BINARY'; } return new Content($this->part->getContent(), $contentType, $contentTransferEncoding, $encoding); }
/** * @return null|string */ protected function getContentDispositionValue() { return $this->part->getHeaders()->has('Content-Disposition') ? $this->part->getHeader('Content-Disposition')->getFieldValue() : null; }
/** * Gets a header in specified format * * @param string $name The name of header, matches case-insensitive, but camel-case is replaced with dashes * @param string $format change The type of return value to 'string' or 'array' * @return Headers */ public function getHeader($name, $format = null) { return $this->part->getHeader($name, $format); }
/** * Gets the Content-Disposition for the given part * * @param Part $part The message part * @param bool $format Can be FORMAT_RAW or FORMAT_ENCODED, see HeaderInterface::FORMAT_* constants * * @return string|null */ protected function getPartContentDisposition($part, $format = HeaderInterface::FORMAT_RAW) { return $part->getHeaders()->has('Content-Disposition') ? $part->getHeader('Content-Disposition')->getFieldValue($format) : null; }
/** * Gets the Content-Type for the given part * * @param Part $part The message part * @return \Zend\Mail\Header\ContentType|null */ protected function getPartContentType($part) { return $part->getHeaders()->has('Content-Type') ? $part->getHeader('Content-Type') : null; }