Copied!

Provides common Message helper routines for Message manipulation.

CloneableInstantiable
Methods
public ZBateson\MailMimeParser\Message\Helper\AbstractHelper::__construct(ZBateson\MailMimeParser\Message\Factory\IMimePartFactory $mimePartFactory, ZBateson\MailMimeParser\Message\Factory\IUUEncodedPartFactory $uuEncodedPartFactory)
public copyContentHeadersAndContent(ZBateson\MailMimeParser\Message\IMimePart $from, ZBateson\MailMimeParser\Message\IMimePart $to, $move = false) : static
 

Copies Content-* headers from the $from header into the $to header. If the Content-Type header isn't defined in $from, defaults to text/plain with utf-8 and quoted-printable as its Content-Transfer-Encoding.

An exception is made for the obsolete Content-Return header, which isn't isn't a MIME content field and so isn't copied.

  • param bool $move
public copyHeader(ZBateson\MailMimeParser\Message\IMimePart $from, ZBateson\MailMimeParser\Message\IMimePart $to, $header, $default = NULL) : static
 

Copies the passed $header from $from, to $to or sets the header to $default if it doesn't exist in $from.

  • param string $header
  • param string $default
public createNewContentPartFrom(ZBateson\MailMimeParser\Message\IMimePart $part) : ZBateson\MailMimeParser\Message\IMimePart
 

Creates a new content part from the passed part, allowing the part to be used for something else (e.g. changing a non-mime message to a multipart mime message).

  • return \IMimePart the newly-created IMimePart
public movePartContentAndChildren(ZBateson\MailMimeParser\Message\IMimePart $from, ZBateson\MailMimeParser\Message\IMimePart $to) : static
 

Copies type headers (Content-Type, Content-Disposition, Content-Transfer-Encoding) from the $from MimePart to $to. Attaches the content resource handle of $from to $to, and loops over child parts, removing them from $from and adding them to $to.

public removeContentHeadersAndContent(ZBateson\MailMimeParser\Message\IMimePart $part) : static
 

Removes Content-* headers from the passed part, then detaches its content stream.

An exception is made for the obsolete Content-Return header, which isn't isn't a MIME content field and so isn't removed.

public replacePart(ZBateson\MailMimeParser\IMessage $message, ZBateson\MailMimeParser\Message\IMimePart $part, ZBateson\MailMimeParser\Message\IMimePart $replacement) : static
 

Replaces the $part IMimePart with $replacement.

Essentially removes $part from its parent, and adds $replacement in its same position. If $part is the IMessage, then $part can't be removed and replaced, and instead $replacement's type headers are copied to $message, and any children below $replacement are added directly below $message.

Properties
protected ZBateson\MailMimeParser\Message\Factory\IMimePartFactory ZBateson\MailMimeParser\Message\Helper\AbstractHelper::$mimePartFactory
 
  • var \IMimePartFactory to create parts for attachments/content
protected ZBateson\MailMimeParser\Message\Factory\IUUEncodedPartFactory ZBateson\MailMimeParser\Message\Helper\AbstractHelper::$uuEncodedPartFactory
 
  • var \IUUEncodedPartFactory to create parts for attachments
Properties
private static array $nonMimeContentFields = ['contentreturn', 'contentidentifier']
 
  • var string[] non mime content fields that are not related to the content of a part.
Methods
private isMimeContentField(ZBateson\MailMimeParser\Header\IHeader $header, array $exceptions = []) : bool
 

Returns true if the passed header's name is a Content-* header other than one defined in the static $nonMimeContentFields

Properties
private static array $nonMimeContentFields = ['contentreturn', 'contentidentifier']
 
  • var string[] non mime content fields that are not related to the content of a part.
© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration