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(?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( $resource, string $mimeType, ?string $filename = NULL, string $disposition = 'attachment', string $encoding = 'base64')
 
  • return static
public addAttachmentPartFromFile( $filePath, string $mimeType, ?string $filename = NULL, string $disposition = 'attachment', string $encoding = 'base64')
 
  • return static
public ZBateson\MailMimeParser\Message\MultiPart::addChild(ZBateson\MailMimeParser\Message\IMessagePart $part, ?int $position = NULL)
public ZBateson\MailMimeParser\Message\MimePart::addRawHeader(string $name, string $value)
 
  • return 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)
 
  • return static
public ZBateson\MailMimeParser\Message\MessagePart::detach(SplObserver $observer) : void
public ZBateson\MailMimeParser\Message\MessagePart::detachContentStream()
 
  • return static
public static from( $resource, $attached)
 

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.
  • return \IMessage
public getAllAttachmentParts()
public ZBateson\MailMimeParser\Message\MimePart::getAllHeaders()
public ZBateson\MailMimeParser\Message\MimePart::getAllHeadersByName( $name)
public ZBateson\MailMimeParser\Message\MultiPart::getAllParts( $fnFilter = NULL)
public ZBateson\MailMimeParser\Message\MultiPart::getAllPartsByMimeType( $mimeType)
public getAttachmentCount() : int
public getAttachmentPart(int $index)
public ZBateson\MailMimeParser\Message\MessagePart::getBinaryContentResourceHandle()
public ZBateson\MailMimeParser\Message\MessagePart::getBinaryContentStream()
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( $index, $fnFilter = NULL)
public ZBateson\MailMimeParser\Message\MultiPart::getChildCount( $fnFilter = NULL)
public ZBateson\MailMimeParser\Message\MultiPart::getChildIterator()
public ZBateson\MailMimeParser\Message\MultiPart::getChildParts( $fnFilter = NULL)
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)
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( $mimeType)
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( $name, $offset = 0)
public ZBateson\MailMimeParser\Message\MimePart::getHeaderAs(string $name, string $iHeaderClass, int $offset = 0) : ?ZBateson\MailMimeParser\Header\IHeader
public ZBateson\MailMimeParser\Message\MimePart::getHeaderParameter( $header, $param, $defaultValue = NULL)
public ZBateson\MailMimeParser\Message\MimePart::getHeaderValue( $name, $defaultValue = NULL)
public getHtmlContent( $index = 0, $charset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET)
public getHtmlPart( $index = 0)
public getHtmlPartCount()
public getHtmlStream( $index = 0, $charset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET)
public ZBateson\MailMimeParser\Message\MessagePart::getParent()
public ZBateson\MailMimeParser\Message\MultiPart::getPart( $index, $fnFilter = NULL)
public ZBateson\MailMimeParser\Message\MultiPart::getPartByContentId( $contentId)
public ZBateson\MailMimeParser\Message\MultiPart::getPartByMimeType( $mimeType, $index = 0)
public ZBateson\MailMimeParser\Message\MultiPart::getPartCount( $fnFilter = NULL)
public ZBateson\MailMimeParser\Message\MimePart::getRawHeaderIterator()
public ZBateson\MailMimeParser\Message\MimePart::getRawHeaders()
public ZBateson\MailMimeParser\Message\MessagePart::getResourceHandle()
public getSignaturePart()
public getSignedMessageAsString()
public getSignedMessageStream()
public ZBateson\MailMimeParser\Message\MessagePart::getStream()
public getTextContent( $index = 0, $charset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET)
public getTextPart( $index = 0)
public getTextPartCount()
public getTextStream( $index = 0, $charset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET)
public ZBateson\MailMimeParser\Message\MessagePart::hasContent() : 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()
public ZBateson\MailMimeParser\Message\MimePart::isSignaturePart()
 

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

  • return bool
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( $fnFilter = NULL) : int
public removeAllTextParts(bool $moveRelatedPartsBelowMessage = true) : bool
public removeAttachmentPart(int $index) : self
public ZBateson\MailMimeParser\Message\MimePart::removeHeader(string $name)
 
  • return 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)
 
  • return static
public removeTextPart(int $index = 0) : bool
public ZBateson\MailMimeParser\Message\MessagePart::save( $filenameResourceOrStream, string $filemode = 'w+')
 
  • return static
public ZBateson\MailMimeParser\Message\MessagePart::saveContent( $filenameResourceOrStream) : self
public setAsMultipartSigned(string $micalg, string $protocol)
 
  • return static
public ZBateson\MailMimeParser\Message\MessagePart::setCharsetOverride(string $charsetOverride, bool $onlyIfNoCharset = false)
 
  • return static
public ZBateson\MailMimeParser\Message\MessagePart::setContent( $resource, string $charset = 'UTF-8'ZBateson\MailMimeParser\MailMimeParser::DEFAULT_CHARSET)
 
  • return static
public setHtmlPart( $resource, string $charset = 'UTF-8') : self
public ZBateson\MailMimeParser\Message\MimePart::setRawHeader(string $name, ?string $value, int $offset = 0)
 
  • return static
public setSignature(string $body) : self
public setTextPart( $resource, string $charset = 'UTF-8')
 
  • return static
Properties
protected 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\MimePart::$headerContainer = NULL
 
  • var \PartHeaderContainer Container for this part's headers.
protected ZBateson\MailMimeParser\Message\MessagePart::$ignoreTransferEncoding = NULL
 
  • 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 ZBateson\MailMimeParser\Message\MessagePart::$observers = NULL
 
  • var \SplObjectStorage attached observers that need to be notified of modifications to this part.
protected ZBateson\MailMimeParser\Message\MessagePart::$parent = NULL
 
  • var ?\IMimePart parent part
protected ZBateson\MailMimeParser\Message\MultiPart::$partChildrenContainer = NULL
 
  • var \PartChildrenContainer child part container
protected ZBateson\MailMimeParser\Message\MessagePart::$partStreamContainer = NULL
 
  • var \PartStreamContainer holds 'stream' and 'content stream'.
Properties
private $multipartHelper = NULL
 
  • var \MultipartHelper service providing functions for multipart messages.
private $privacyHelper = NULL
 
  • var \PrivacyHelper service providing functions for multipart/signed messages.
Methods
public static from( $resource, $attached)
 

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.
  • return \IMessage
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration