MailMimeParser 0.4

AddressGroupPart extends MimeLiteralPart

Holds a group of addresses, and an optional group name.

Because AddressGroupConsumer is only called once a colon (":") character is found, an AddressGroupPart is initially constructed without a $name. Once it is returned to AddressConsumer, a new AddressGroupPart is created out of AddressGroupConsumer's AddressGroupPart.

Tags
author

Zaahid Bateson

Table of Contents

MIME_PART_PATTERN  = '=\?[A-Za-z\-_0-9]+\?[QBqb]\?[^\?]+\?='
$addresses  : array<string|int, AddressPart>
$canIgnoreSpacesAfter  : bool
$canIgnoreSpacesBefore  : bool
$value  : string
__construct()  : mixed
Creates an AddressGroupPart out of the passed array of AddressParts and an optional name (which may be mime-encoded).
__toString()  : string
Returns the value of the part (which is a string).
getAddress()  : Address
Returns the AddressPart at the passed index or null.
getAddresses()  : array<string|int, AddressPart>
Return the AddressGroupPart's array of addresses.
getName()  : string
Returns the name of the group
getValue()  : string
Returns the part's value.
ignoreSpacesAfter()  : bool
Returns true if spaces after this part should be ignored. True is only returned for MimeLiterals if the part ends with a mime-encoded string Tokens if the Token's value is a single space, and for CommentParts.
ignoreSpacesBefore()  : bool
Returns true if spaces before this part should be ignored. True is only returned for MimeLiterals if the part begins with a mime-encoded string, Tokens if the Token's value is a single space, and for CommentParts.
convertEncoding()  : string
Ensures the encoding of the passed string is set to UTF-8.
decodeMime()  : string
Finds and replaces mime parts with their values.
decodeMatchedEntity()  : string
Decodes a single mime-encoded entity.

Constants

MIME_PART_PATTERN

public string MIME_PART_PATTERN = '=\?[A-Za-z\-_0-9]+\?[QBqb]\?[^\?]+\?='

Properties

$canIgnoreSpacesBefore

protected bool $canIgnoreSpacesBefore = false

Methods

__construct()

Creates an AddressGroupPart out of the passed array of AddressParts and an optional name (which may be mime-encoded).

public __construct(array<string|int, AddressPart$addresses[, string $name = '' ]) : mixed
Parameters
$addresses : array<string|int, AddressPart>
$name : string = ''
Return values
mixed

__toString()

Returns the value of the part (which is a string).

public __toString() : string
Return values
string

the value

getAddress()

Returns the AddressPart at the passed index or null.

public getAddress(int $index) : Address
Parameters
$index : int
Return values
Address

getName()

Returns the name of the group

public getName() : string
Return values
string

getValue()

Returns the part's value.

public getValue() : string
Return values
string

the value of the part

ignoreSpacesAfter()

Returns true if spaces after this part should be ignored. True is only returned for MimeLiterals if the part ends with a mime-encoded string Tokens if the Token's value is a single space, and for CommentParts.

public ignoreSpacesAfter() : bool
Return values
bool

ignoreSpacesBefore()

Returns true if spaces before this part should be ignored. True is only returned for MimeLiterals if the part begins with a mime-encoded string, Tokens if the Token's value is a single space, and for CommentParts.

public ignoreSpacesBefore() : bool
Return values
bool

convertEncoding()

Ensures the encoding of the passed string is set to UTF-8.

protected convertEncoding(string $str) : string
Parameters
$str : string
Return values
string

utf-8 string

decodeMime()

Finds and replaces mime parts with their values.

protected decodeMime(string $value) : string

The method splits the token value into an array on mime-part-patterns, either replacing a mime part with its value by calling iconv_mime_decode or converts the encoding on the text part by calling convertEncoding.

Parameters
$value : string
Return values
string

decodeMatchedEntity()

Decodes a single mime-encoded entity.

private decodeMatchedEntity(string $entity) : string

Unfortunately, mb_decode_header fails for many charsets on PHP 5.4 and PHP 5.5 (even if they're listed as supported). iconv_mime_decode doesn't support all charsets.

Parsing out the charset and body of the encoded entity seems to be the way to go to support the most charsets.

Parameters
$entity : string
Return values
string

Search results