PHP Class PhpMimeMailParser\Parser

Fully Tested Mailparse Extension Wrapper for PHP 5.4+
Exibir arquivo Open project: exorus/php-mime-mail-parser Class Usage Examples

Protected Properties

Property Type Description
$charset object
$data string A text of an email
$parts array Parts of an email
$resource resource PHP MimeParser Resource ID
$stream resource A file pointer to email

Public Methods

Method Description
__construct ( PhpMimeMailParser\Contracts\CharsetManager $charset = null ) Parser constructor.
__destruct ( ) : void Free the held resources
getAddresses ( string $name ) : array Return an array with the following keys display, address, is_group
getAttachments ( $include_inline = true ) : Attachment[] Returns the attachments contents in order of appearance
getCharset ( ) : PhpMimeMailParser\Contracts\CharsetManager Retrieve the charset manager object
getData ( ) : string Retrieve the text of an email
getHeader ( string $name ) : string Retrieve a specific Email Header
getHeaders ( ) : array Retrieve all mail headers
getHeadersRaw ( ) : string Retrieve the raw mail headers as a string
getMessageBody ( string $type = 'text' ) : false | string Returns the email message body in the specified format
getParts ( ) : array Retrieve the parts of an email
getRawHeader ( string $name ) : string Retrieve a specific Email Header, without charset conversion.
getResource ( ) : resource Retrieve the resource
getStream ( ) : resource Retrieve the file pointer to email
saveAttachments ( string $attach_dir, $include_inline = true ) : array Save attachments in a folder
setPath ( string $path ) : Parser Set the file path we use to get the email text
setStream ( resource $stream ) : Parser Set the Stream resource we use to get the email text
setText ( string $data ) : Parser Set the email text

Protected Methods

Method Description
decodeContentTransfer ( string $encodedString, string $encodingType ) : string Decode the string from Content-Transfer-Encoding
decodeHeader ( string | array $input ) : string $input can be a string or array
decodeSingleHeader ( string $input ) : string Decodes a single header (= string)
getAttachmentStream ( array &$part ) : resource Read the attachment Body and save temporary file resource
getEmbeddedData ( string $contentId ) : string Returns the embedded data structure
getPart ( string $type, array $parts ) : string | array Retrieve a specified MIME part
getPartBody ( array &$part ) : string Retrieve the Body of a MIME part
getPartBodyFromFile ( array &$part ) : string Retrieve the Body from a MIME part from file
getPartBodyFromText ( array &$part ) : string Retrieve the Body from a MIME part from text
getPartCharset ( array $part ) : string | false Return the charset of the MIME part
getPartComplete ( array &$part ) : string Retrieve the content of a MIME part
getPartFromFile ( array &$part ) : string Retrieve the content from a MIME part from file
getPartFromText ( array &$part ) : string Retrieve the content from a MIME part from text
getPartHeader ( &$part ) : String Retrieve the raw Header of a MIME part
getPartHeaderFromFile ( &$part ) : String Retrieve the Header from a MIME part from file
getPartHeaderFromText ( &$part ) : String Retrieve the Header from a MIME part from text
parse ( ) : void Parse the Message into parts

Method Details

__construct() public method

Parser constructor.
public __construct ( PhpMimeMailParser\Contracts\CharsetManager $charset = null )
$charset PhpMimeMailParser\Contracts\CharsetManager

__destruct() public method

Free the held resources
public __destruct ( ) : void
return void

decodeContentTransfer() protected method

Decode the string from Content-Transfer-Encoding
protected decodeContentTransfer ( string $encodedString, string $encodingType ) : string
$encodedString string The string in its original encoded state
$encodingType string The encoding type from the Content-Transfer-Encoding header of the part.
return string The decoded string

decodeHeader() protected method

$input can be a string or array
protected decodeHeader ( string | array $input ) : string
$input string | array
return string

decodeSingleHeader() protected method

Decodes a single header (= string)
protected decodeSingleHeader ( string $input ) : string
$input string
return string

getAddresses() public method

Return an array with the following keys display, address, is_group
public getAddresses ( string $name ) : array
$name string Header name (case-insensitive)
return array

getAttachmentStream() protected method

Read the attachment Body and save temporary file resource
protected getAttachmentStream ( array &$part ) : resource
$part array
return resource Mime Body Part

getAttachments() public method

Returns the attachments contents in order of appearance
public getAttachments ( $include_inline = true ) : Attachment[]
return Attachment[]

getCharset() public method

Retrieve the charset manager object
public getCharset ( ) : PhpMimeMailParser\Contracts\CharsetManager
return PhpMimeMailParser\Contracts\CharsetManager charset

getData() public method

Retrieve the text of an email
public getData ( ) : string
return string data

getEmbeddedData() protected method

Returns the embedded data structure
protected getEmbeddedData ( string $contentId ) : string
$contentId string Content-Id
return string

getHeader() public method

Retrieve a specific Email Header
public getHeader ( string $name ) : string
$name string Header name (case-insensitive)
return string

getHeaders() public method

Retrieve all mail headers
public getHeaders ( ) : array
return array

getHeadersRaw() public method

Retrieve the raw mail headers as a string
public getHeadersRaw ( ) : string
return string

getMessageBody() public method

Returns the email message body in the specified format
public getMessageBody ( string $type = 'text' ) : false | string
$type string text, html or htmlEmbedded
return false | string Body or False if not found

getPart() protected method

Retrieve a specified MIME part
protected getPart ( string $type, array $parts ) : string | array
$type string
$parts array
return string | array

getPartBody() protected method

Retrieve the Body of a MIME part
protected getPartBody ( array &$part ) : string
$part array
return string

getPartBodyFromFile() protected method

Retrieve the Body from a MIME part from file
protected getPartBodyFromFile ( array &$part ) : string
$part array
return string Mime Body Part

getPartBodyFromText() protected method

Retrieve the Body from a MIME part from text
protected getPartBodyFromText ( array &$part ) : string
$part array
return string Mime Body Part

getPartCharset() protected method

Return the charset of the MIME part
protected getPartCharset ( array $part ) : string | false
$part array
return string | false

getPartComplete() protected method

Retrieve the content of a MIME part
protected getPartComplete ( array &$part ) : string
$part array
return string

getPartFromFile() protected method

Retrieve the content from a MIME part from file
protected getPartFromFile ( array &$part ) : string
$part array
return string Mime Content

getPartFromText() protected method

Retrieve the content from a MIME part from text
protected getPartFromText ( array &$part ) : string
$part array
return string Mime Content

getPartHeader() protected method

Retrieve the raw Header of a MIME part
protected getPartHeader ( &$part ) : String
$part Object
return String

getPartHeaderFromFile() protected method

Retrieve the Header from a MIME part from file
protected getPartHeaderFromFile ( &$part ) : String
$part Array
return String Mime Header Part

getPartHeaderFromText() protected method

Retrieve the Header from a MIME part from text
protected getPartHeaderFromText ( &$part ) : String
$part Array
return String Mime Header Part

getParts() public method

Retrieve the parts of an email
public getParts ( ) : array
return array parts

getRawHeader() public method

Retrieve a specific Email Header, without charset conversion.
public getRawHeader ( string $name ) : string
$name string Header name (case-insensitive)
return string

getResource() public method

Retrieve the resource
public getResource ( ) : resource
return resource resource

getStream() public method

Retrieve the file pointer to email
public getStream ( ) : resource
return resource stream

parse() protected method

Parse the Message into parts
protected parse ( ) : void
return void

saveAttachments() public method

Save attachments in a folder
public saveAttachments ( string $attach_dir, $include_inline = true ) : array
$attach_dir string directory
return array Saved attachments paths

setPath() public method

Set the file path we use to get the email text
public setPath ( string $path ) : Parser
$path string File path to the MIME mail
return Parser MimeMailParser Instance

setStream() public method

Set the Stream resource we use to get the email text
public setStream ( resource $stream ) : Parser
$stream resource
return Parser MimeMailParser Instance

setText() public method

Set the email text
public setText ( string $data ) : Parser
$data string
return Parser MimeMailParser Instance

Property Details

$charset protected_oe property

object
protected $charset

$data protected_oe property

A text of an email
protected string $data
return string

$parts protected_oe property

Parts of an email
protected array $parts
return array

$resource protected_oe property

PHP MimeParser Resource ID
protected resource $resource
return resource

$stream protected_oe property

A file pointer to email
protected resource $stream
return resource