Copied!

An email message.

The message could represent a simple text email, a multipart message with children, or a non-mime message containing UUEncoded parts.

CloneableInstantiable
Methods
public __construct(?Psr\Log\LoggerInterface $logger = NULL, ?ZBateson\MailMimeParser\Message\PartStreamContainer $streamContainer = NULL, ?ZBateson\MailMimeParser\Message\PartHeaderContainer $headerContainer = NULL, ?ZBateson\MailMimeParser\Message\PartChildrenContainer $partChildrenContainer = NULL, ?ZBateson\MailMimeParser\Message\Helper\MultipartHelper $multipartHelper = NULL, ?ZBateson\MailMimeParser\Message\Helper\PrivacyHelper $privacyHelper = NULL)
public ZBateson\MailMimeParser\Message\MessagePart::__toString() : string
public addAttachmentPart(?mixed $resource, string $mimeType, ?string $filename = NULL, string $disposition = 'attachment', string $encoding = 'base64') : static
public addAttachmentPartFromFile(string $filePath, string $mimeType, ?string $filename = NULL, string $disposition = 'attachment', string $encoding = 'base64') : static
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 ZBateson\MailMimeParser\Message\MimePart::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 static from(?mixed $resource, bool $attached) : ZBateson\MailMimeParser\IMessage
 

Convenience method to parse a handle or string into an IMessage without requiring including MailMimeParser, instantiating it, and calling parse.

If the passed $resource is a resource handle or StreamInterface, the resource must remain open while the returned IMessage object exists. Pass true as the second argument to have the resource attached to the IMessage and closed for you when it's destroyed, or pass false to manually close it if it should remain open after the IMessage object is destroyed.

  • param resource|\StreamInterface|string $resource The resource handle to the input stream of the mime message, or a string containing a mime message.
  • param bool $attached pass true to have it attached to the returned IMessage and destroyed with it.
public getAllAttachmentParts() : array
public ZBateson\MailMimeParser\ErrorBag::getAllErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : array
public ZBateson\MailMimeParser\Message\MimePart::getAllHeaders() : array
public ZBateson\MailMimeParser\Message\MimePart::getAllHeadersByName(string $name) : array
public ZBateson\MailMimeParser\Message\MultiPart::getAllParts(?callable $fnFilter = NULL) : array
public ZBateson\MailMimeParser\Message\MultiPart::getAllPartsByMimeType(string $mimeType) : array
public getAttachmentCount() : int
public getAttachmentPart(int $index) : ?ZBateson\MailMimeParser\Message\IMessagePart
public ZBateson\MailMimeParser\Message\MessagePart::getBinaryContentResourceHandle() : ?mixed
public ZBateson\MailMimeParser\Message\MessagePart::getBinaryContentStream() : ?ZBateson\MailMimeParser\Stream\MessagePartStreamDecorator
public ZBateson\MailMimeParser\Message\MimePart::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 ZBateson\MailMimeParser\Message\MimePart::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'.
  • return string the content disposition
public ZBateson\MailMimeParser\Message\MimePart::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 ZBateson\MailMimeParser\Message\MimePart::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.
  • return string the content transfer encoding.
public ZBateson\MailMimeParser\Message\MimePart::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.
  • return string the mime type
public ZBateson\MailMimeParser\Message\MultiPart::getCountOfPartsByMimeType(string $mimeType) : int
public ZBateson\MailMimeParser\Message\MimePart::getErrorBagChildren() : array
public getErrorLoggingContextName() : string
public ZBateson\MailMimeParser\ErrorBag::getErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : array
public ZBateson\MailMimeParser\Message\MimePart::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 ZBateson\MailMimeParser\Message\MimePart::getHeader(string $name, int $offset = 0) : ?ZBateson\MailMimeParser\Header\IHeader
public ZBateson\MailMimeParser\Message\MimePart::getHeaderAs(string $name, string $iHeaderClass, int $offset = 0) : ?ZBateson\MailMimeParser\Header\IHeader
public ZBateson\MailMimeParser\Message\MimePart::getHeaderParameter(string $header, string $param, ?string $defaultValue = NULL) : ?string
public ZBateson\MailMimeParser\Message\MimePart::getHeaderValue(string $name, ?string $defaultValue = NULL) : ?string
public getHtmlContent(int $index = 0, string $charset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET) : ?string
public getHtmlPart(int $index = 0) : ?ZBateson\MailMimeParser\Message\IMessagePart
public getHtmlPartCount() : int
public getHtmlStream(int $index = 0, string $charset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET) : ?Psr\Http\Message\StreamInterface
public getMessageId() : ?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 ZBateson\MailMimeParser\Message\MimePart::getRawHeaderIterator() : Traversable
public ZBateson\MailMimeParser\Message\MimePart::getRawHeaders() : array
public ZBateson\MailMimeParser\Message\MessagePart::getResourceHandle() : ?mixed
public getSignaturePart() : ?ZBateson\MailMimeParser\Message\IMessagePart
public getSignedMessageAsString() : ?string
public getSignedMessageStream() : ?Psr\Http\Message\StreamInterface
public ZBateson\MailMimeParser\Message\MessagePart::getStream() : Psr\Http\Message\StreamInterface
public getSubject() : ?string
public getTextContent(int $index = 0, string $charset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET) : ?string
public getTextPart(int $index = 0) : ?ZBateson\MailMimeParser\Message\IMessagePart
public getTextPartCount() : int
public getTextStream(int $index = 0, string $charset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET) : ?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 if the current part is a mime part.

The message is considered 'mime' if it has either a Content-Type or MIME-Version header defined.

public ZBateson\MailMimeParser\Message\MimePart::isMultiPart() : bool
public ZBateson\MailMimeParser\Message\MimePart::isSignaturePart() : bool
 

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

public ZBateson\MailMimeParser\Message\MimePart::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 removeAllHtmlParts(bool $moveRelatedPartsBelowMessage = true) : bool
public ZBateson\MailMimeParser\Message\MultiPart::removeAllParts(?callable $fnFilter = NULL) : int
public removeAllTextParts(bool $moveRelatedPartsBelowMessage = true) : bool
public removeAttachmentPart(int $index) : static
public ZBateson\MailMimeParser\Message\MimePart::removeHeader(string $name) : static
public removeHtmlPart(int $index = 0) : bool
public ZBateson\MailMimeParser\Message\MultiPart::removePart(ZBateson\MailMimeParser\Message\IMessagePart $part) : ?int
public ZBateson\MailMimeParser\Message\MimePart::removeSingleHeader(string $name, int $offset = 0) : static
public removeTextPart(int $index = 0) : bool
public ZBateson\MailMimeParser\Message\MessagePart::save( $filenameResourceOrStream, string $filemode = 'w+') : static
public ZBateson\MailMimeParser\Message\MessagePart::saveContent( $filenameResourceOrStream) : static
public setAsMultipartSigned(string $micalg, string $protocol) : 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 setHtmlPart(?mixed $resource, string $charset = 'UTF-8') : static
public ZBateson\MailMimeParser\Message\MimePart::setRawHeader(string $name, ?string $value, int $offset = 0) : static
public setSignature(string $body) : static
public setTextPart(?mixed $resource, string $charset = 'UTF-8') : 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.
protected ZBateson\MailMimeParser\Message\PartHeaderContainer ZBateson\MailMimeParser\Message\MimePart::$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.
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.
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.

Properties
private ZBateson\MailMimeParser\Message\Helper\MultipartHelper $multipartHelper
 
  • var \MultipartHelper service providing functions for multipart messages.
private ZBateson\MailMimeParser\Message\Helper\PrivacyHelper $privacyHelper
 
  • var \PrivacyHelper service providing functions for multipart/signed messages.
Methods
public static from(?mixed $resource, bool $attached) : ZBateson\MailMimeParser\IMessage
 

Convenience method to parse a handle or string into an IMessage without requiring including MailMimeParser, instantiating it, and calling parse.

If the passed $resource is a resource handle or StreamInterface, the resource must remain open while the returned IMessage object exists. Pass true as the second argument to have the resource attached to the IMessage and closed for you when it's destroyed, or pass false to manually close it if it should remain open after the IMessage object is destroyed.

  • param resource|\StreamInterface|string $resource The resource handle to the input stream of the mime message, or a string containing a mime message.
  • param bool $attached pass true to have it attached to the returned IMessage and destroyed with it.
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration