Copied!

A mime email message part.

A MIME part may contain any combination of headers, content and children.

CloneableInstantiable
Methods
public __construct(?ZBateson\MailMimeParser\Message\IMimePart $parent = NULL, ?Psr\Log\LoggerInterface $logger = NULL, ?ZBateson\MailMimeParser\Message\PartStreamContainer $streamContainer = NULL, ?ZBateson\MailMimeParser\Message\PartHeaderContainer $headerContainer = NULL, ?ZBateson\MailMimeParser\Message\PartChildrenContainer $partChildrenContainer = NULL)
public ZBateson\MailMimeParser\Message\MessagePart::__toString() : string
public ZBateson\MailMimeParser\Message\MultiPart::addChild(ZBateson\MailMimeParser\Message\MessagePart $part, ?int $position = NULL) : static
public ZBateson\MailMimeParser\ErrorBag::addError(string $message, string $psrLogLevel, ?Throwable $exception = NULL) : static
public addRawHeader(string $name, string $value) : static
public ZBateson\MailMimeParser\Message\MessagePart::attach(SplObserver $observer) : void
public ZBateson\MailMimeParser\Message\MessagePart::attachContentStream(Psr\Http\Message\StreamInterface $stream, string $streamCharset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET) : static
public ZBateson\MailMimeParser\Message\MessagePart::detach(SplObserver $observer) : void
public ZBateson\MailMimeParser\Message\MessagePart::detachContentStream() : static
public ZBateson\MailMimeParser\ErrorBag::getAllErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : array
public getAllHeaders() : array
public getAllHeadersByName(string $name) : array
public ZBateson\MailMimeParser\Message\MultiPart::getAllParts(?callable $fnFilter = NULL) : array
public ZBateson\MailMimeParser\Message\MultiPart::getAllPartsByMimeType(string $mimeType) : array
public ZBateson\MailMimeParser\Message\MessagePart::getBinaryContentResourceHandle() : ?mixed
public ZBateson\MailMimeParser\Message\MessagePart::getBinaryContentStream() : ?ZBateson\MailMimeParser\Stream\MessagePartStreamDecorator
public getCharset() : ?string
 

Returns the charset of the content, or null if not applicable/defined.

Looks for a 'charset' parameter under the 'Content-Type' header of this part and returns it if set, defaulting to 'ISO-8859-1' if the Content-Type header exists and is of type text/plain or text/html.

Note that the returned value is also converted to upper case.

  • return string|null the charset
public ZBateson\MailMimeParser\Message\MultiPart::getChild(int $index, ?callable $fnFilter = NULL) : ?ZBateson\MailMimeParser\Message\IMessagePart
public ZBateson\MailMimeParser\Message\MultiPart::getChildCount(?callable $fnFilter = NULL) : int
public ZBateson\MailMimeParser\Message\MultiPart::getChildIterator() : RecursiveIterator
public ZBateson\MailMimeParser\Message\MultiPart::getChildParts(?callable $fnFilter = NULL) : array
public ZBateson\MailMimeParser\Message\MessagePart::getContent(string $charset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET) : ?string
public getContentDisposition(?string $default = 'inline') : ?string
 

Returns the content's disposition, or returns the value of $default if not defined.

Looks at the 'Content-Disposition' header, which should only contain either 'inline' or 'attachment'. If the header is not one of those values, $default is returned, which defaults to 'inline' unless passed something else.

  • param string $default Optional default value if not set or does not match 'inline' or 'attachment'. match 'inline' or 'attachment'.
  • return string the content disposition
public getContentId() : ?string
 

Returns the Content ID of the part, or null if not defined.

Looks up and returns the value of the 'Content-ID' header.

  • return string|null the content ID or null if not defined.
public ZBateson\MailMimeParser\Message\MessagePart::getContentStream(string $charset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET) : ?ZBateson\MailMimeParser\Stream\MessagePartStreamDecorator
public getContentTransferEncoding(?string $default = '7bit') : ?string
 

Returns the content transfer encoding used to encode the content on this part, or the value of $default if not defined.

Looks up and returns the value of the 'Content-Transfer-Encoding' header if set, defaulting to '7bit' if an alternate $default param is not passed.

The returned value is always lowercase, and header values of 'x-uue', 'uue' and 'uuencode' will return 'x-uuencode' instead.

  • param string $default Optional default value to return if the header isn't set. isn't set.
  • return string the content transfer encoding.
public getContentType(string $default = 'text/plain') : ?string
 

Returns the mime type of the content, or $default if one is not set.

Looks at the part's Content-Type header and returns its value if set, or defaults to 'text/plain'.

Note that the returned value is converted to lower case, and may not be identical to calling {@see MimePart::getHeaderValue('Content-Type')} in some cases.

  • param string $default Optional default value to specify a default other than text/plain if needed. than text/plain if needed.
  • return string the mime type
public ZBateson\MailMimeParser\Message\MultiPart::getCountOfPartsByMimeType(string $mimeType) : int
public getErrorBagChildren() : array
public ZBateson\MailMimeParser\Message\MessagePart::getErrorLoggingContextName() : string
public ZBateson\MailMimeParser\ErrorBag::getErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : array
public getFilename() : ?string
 

Returns a filename for the part if one is defined, or null otherwise.

Uses the 'filename' parameter of the Content-Disposition header if it exists, or the 'name' parameter of the 'Content-Type' header if it doesn't.

  • return string|null the file name of the part or null.
public getHeader(string $name, int $offset = 0) : ?ZBateson\MailMimeParser\Header\IHeader
public getHeaderAs(string $name, string $iHeaderClass, int $offset = 0) : ?ZBateson\MailMimeParser\Header\IHeader
public getHeaderParameter(string $header, string $param, ?string $defaultValue = NULL) : ?string
public getHeaderValue(string $name, ?string $defaultValue = NULL) : ?string
public ZBateson\MailMimeParser\Message\MessagePart::getParent() : ?ZBateson\MailMimeParser\Message\IMimePart
public ZBateson\MailMimeParser\Message\MultiPart::getPart(int $index, ?callable $fnFilter = NULL) : ?ZBateson\MailMimeParser\Message\IMessagePart
public ZBateson\MailMimeParser\Message\MultiPart::getPartByContentId(string $contentId) : ?ZBateson\MailMimeParser\Message\IMessagePart
public ZBateson\MailMimeParser\Message\MultiPart::getPartByMimeType(string $mimeType, int $index = 0) : ?ZBateson\MailMimeParser\Message\IMessagePart
public ZBateson\MailMimeParser\Message\MultiPart::getPartCount(?callable $fnFilter = NULL) : int
public getRawHeaderIterator() : Traversable
public getRawHeaders() : array
public ZBateson\MailMimeParser\Message\MessagePart::getResourceHandle() : ?mixed
public ZBateson\MailMimeParser\Message\MessagePart::getStream() : Psr\Http\Message\StreamInterface
public ZBateson\MailMimeParser\ErrorBag::hasAnyErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : bool
public ZBateson\MailMimeParser\Message\MessagePart::hasContent() : bool
public ZBateson\MailMimeParser\ErrorBag::hasErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : bool
public isMime() : bool
 

Returns true.

public isMultiPart() : bool
public isSignaturePart() : bool
 

Returns true if this part's parent is an IMessage, and is the same part returned by {@see IMessage::getSignaturePart()}.

public isTextPart() : bool
 

Returns true if this part has a defined 'charset' on its Content-Type header.

This may result in some false positives if charset is set on a part that is not plain text which has been seen. If a part is known to be binary, it's better to use {@see \IMessagePart::getBinaryContentStream()} to avoid issues, or to call {@see \IMessagePart::saveContent()} directly if saving a part's content.

public ZBateson\MailMimeParser\Message\MessagePart::notify() : void
public ZBateson\MailMimeParser\Message\MultiPart::removeAllParts(?callable $fnFilter = NULL) : int
public removeHeader(string $name) : static
public ZBateson\MailMimeParser\Message\MultiPart::removePart(ZBateson\MailMimeParser\Message\IMessagePart $part) : ?int
public removeSingleHeader(string $name, int $offset = 0) : static
public ZBateson\MailMimeParser\Message\MessagePart::save( $filenameResourceOrStream, string $filemode = 'w+') : static
public ZBateson\MailMimeParser\Message\MessagePart::saveContent( $filenameResourceOrStream) : static
public ZBateson\MailMimeParser\Message\MessagePart::setCharsetOverride(string $charsetOverride, bool $onlyIfNoCharset = false) : static
public ZBateson\MailMimeParser\Message\MessagePart::setContent( $resource, string $charset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET) : static
public setRawHeader(string $name, ?string $value, int $offset = 0) : static
Properties
protected ?string ZBateson\MailMimeParser\Message\MessagePart::$charsetOverride = NULL
 
  • var ?string can be used to set an override for content's charset in cases where a user knows the charset on the content is not what it claims to be. to be.
protected ZBateson\MailMimeParser\Message\PartHeaderContainer $headerContainer
 
  • var \PartHeaderContainer Container for this part's headers.
protected bool ZBateson\MailMimeParser\Message\MessagePart::$ignoreTransferEncoding = false
 
  • var bool set to true when a user attaches a stream manually, it's assumed to already be decoded or to have relevant transfer encoding decorators attached already. decorators attached already.
protected Psr\Log\LoggerInterface ZBateson\MailMimeParser\ErrorBag::$logger
protected SplObjectStorage ZBateson\MailMimeParser\Message\MessagePart::$observers
 
  • var \SplObjectStorage attached observers that need to be notified of modifications to this part. modifications to this part.
protected ?ZBateson\MailMimeParser\Message\IMimePart ZBateson\MailMimeParser\Message\MessagePart::$parent
 
  • var ?\IMimePart parent part
protected ZBateson\MailMimeParser\Message\PartChildrenContainer ZBateson\MailMimeParser\Message\MultiPart::$partChildrenContainer
 
  • var \PartChildrenContainer child part container
protected ZBateson\MailMimeParser\Message\PartStreamContainer ZBateson\MailMimeParser\Message\MessagePart::$partStreamContainer
 
  • var \PartStreamContainer holds 'stream' and 'content stream'.
Methods
protected ZBateson\MailMimeParser\ErrorBag::validate() : void
 

Perform any extra validation and call 'addError'.

getErrors and getAllErrors call validate() if their $validate parameter is true. validate() is only called once on an object with getErrors getAllErrors.

© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration