Represents a Received header.

The returned header value (as returned by a call to {@see ReceivedHeader::getValue()}) for a ReceivedHeader is the same as the raw value (as returned by a call to \ZBateson\MailMimeParser\Header\ReceivedHeader::getRawValue()) since the header doesn't have a single 'value' to extract.

The parsed parts of a Received header can be accessed as parameters. To check if a part exists, call \ZBateson\MailMimeParser\Header\ReceivedHeader::hasParameter() with the name of the part, for example: $header->hasParameter('from') or $header->hasParameter('id'). The value of the part can be obtained by calling \ZBateson\MailMimeParser\Header\ReceivedHeader::getValueFor(), for example $header->getValueFor('with');.

Additional parsing is performed on the "FROM" and "BY" parts of a received header in an attempt to extract the self-identified name of the server, its hostname, and its address (depending on what's included). These can be accessed directly from the ReceivedHeader object by calling one of the following methods:

o \ZBateson\MailMimeParser\Header\ReceivedHeader::getFromName() -- the name portion of the FROM part o \ZBateson\MailMimeParser\Header\ReceivedHeader::getFromHostname() -- the hostname of the FROM part o \ZBateson\MailMimeParser\Header\ReceivedHeader::getFromAddress() -- the adddress portion of the FROM part o \ZBateson\MailMimeParser\Header\ReceivedHeader::getByName() -- same as getFromName, but for the BY part, and etc... below o \ZBateson\MailMimeParser\Header\ReceivedHeader::getByHostname() o \ZBateson\MailMimeParser\Header\ReceivedHeader::getByAddress()

The parsed parts of the FROM and BY parts are determined as follows:

o Anything outside and before a parenthesized expression is considered "the name", for example "FROM AlainDeBotton", "AlainDeBotton" would be the name, but also if the name is an address, but exists outside the parenthesized expression, it's still considered "the name". For example: "From [1.2.3.4]", getFromName would return "[1.2.3.4]". o A parenthesized expression MUST match what looks like either a domain name on its own, or a domain name and an address. Otherwise the parenthesized expression is considered a comment, and not parsed into hostname and address. The rules are defined loosely because many implementations differ in how strictly they follow the standard. For a domain, it's enough that the expression starts with any alphanumeric character and contains at least one '.', followed by any number of '.', '-' and alphanumeric characters. The address portion must be surrounded in square brackets, and contain any sequence of '.', ':', numbers, and characters 'a' through 'f'. In addition the string 'ipv6' may start the expression (for instance, '[ipv6:::1]' would be valid). A port number may also be considered valid as part of the address, for example: [1.2.3.4:3231]. No additional validation on the address is done, and so an invalid address such as '....' could be returned, so users using the 'address' header are encouraged to validate it before using it. The square brackets are parsed out of the returned address, so the value returned by getFromAddress() would be "2.2.2.2", not "[2.2.2.2]".

The date/time stamp can be accessed as a DateTime object by calling \ZBateson\MailMimeParser\Header\ReceivedHeader::getDateTime().

Parsed comments can be accessed by calling {@see ReceivedHeader::getComments()}. Some implementations may include connection encryption information or other details in non-standardized comments.

author Zaahid Bateson
package MailMimeParser
inherited_from \ZBateson\MailMimeParser\Header\ParameterHeader

 Methods

Assigns the header's name and raw value, then calls getConsumer and setParseHeaderValue to extract a parsed value.

__construct(\ZBateson\MailMimeParser\Header\Consumer\ConsumerService $consumerService, string $name, string $value) 
Inherited

Parameters

$consumerService

\ZBateson\MailMimeParser\Header\Consumer\ConsumerService

$name

string

$value

string

Returns the string representation of the header. At the moment this is just in the form of:

__toString() : string
Inherited
: No additional processing is performed (for instance to wrap long lines.)

Returns

string

Returns the address part of a parenthesized BY part.

getByAddress() : string

For example, "BY name ([1.2.3.4])" would return the string "1.2.3.4". Validation of the address is not performed, and the returned value may not be valid. More details on how the value is parsed and extracted can be found in the class description for \ReceivedHeader.

Returns

string

Returns the hostname part of a parenthesized BY part.

getByHostname() : string

For example, "BY name (host.name)" would return the string "host.name". Validation of the hostname is not performed, and the returned value may not be valid. More details on how the value is parsed and extracted can be found in the class description for \ReceivedHeader.

Returns

string

Returns the name identified in the BY part of the header.

getByName() : string

The returned value may either be a name or an address in the form "[1.2.3.4]". Validation is not performed on this value, and so whatever exists in this position is returned -- be it contains spaces, or invalid characters, etc...

Returns

string

Returns an array of comments parsed from the header. If there are no comments in the header, an empty array is returned.

getComments() : array<mixed,string>

Returns

array<mixed,string>

Returns the date/time stamp for the received header.

getDateTime() : \DateTime

Returns

\DateTime

Returns the address part of a parenthesized FROM part.

getFromAddress() : string

For example, "FROM name ([1.2.3.4])" would return the string "1.2.3.4". Validation of the address is not performed, and the returned value may not be valid. More details on how the value is parsed and extracted can be found in the class description for \ReceivedHeader.

Returns

string

Returns the hostname part of a parenthesized FROM part.

getFromHostname() : string

For example, "FROM name (host.name)" would return the string "host.name". Validation of the hostname is not performed, and the returned value may not be valid. More details on how the value is parsed and extracted can be found in the class description for \ReceivedHeader.

Returns

string

Returns the name identified in the FROM part of the header.

getFromName() : string

The returned value may either be a name or an address in the form "[1.2.3.4]". Validation is not performed on this value, and so whatever exists in this position is returned -- be it contains spaces, or invalid characters, etc...

Returns

string

Returns the name of the header.

getName() : string
Inherited

Returns

string

Returns an array of HeaderPart objects associated with this header.

getParts() : array<mixed,\ZBateson\MailMimeParser\Header\Part\HeaderPart>
Inherited

Returns

array<mixed,\ZBateson\MailMimeParser\Header\Part\HeaderPart>

Returns the raw value of the header prior to any processing.

getRawValue() : string
Inherited

Returns

string

Returns the raw, unparsed header value, same as {@see ReceivedHeader::getRawValue()}.

getValue() : string

Returns

string

Returns the parsed value of the header -- calls getValue on $this->part

getValue() : string
Inherited

Returns

string

Returns the value of the parameter with the given name, or $defaultValue if not set.

getValueFor(string $name, string $defaultValue = null) : string
Inherited

Parameters

$name

string

$defaultValue

string

Returns

string

Returns true if a parameter exists with the passed name.

hasParameter(string $name) : boolean
Inherited

Parameters

$name

string

Returns

boolean

Returns a ReceivedConsumer.

getConsumer(\ZBateson\MailMimeParser\Header\Consumer\ConsumerService $consumerService) : \ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer
inherited_from \ZBateson\MailMimeParser\Header\ParameterHeader::getConsumer()

Parameters

$consumerService

\ZBateson\MailMimeParser\Header\Consumer\ConsumerService

Returns

\ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer

Returns the header's Consumer

getConsumer(\ZBateson\MailMimeParser\Header\Consumer\ConsumerService $consumerService) : \ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer
Inherited

Parameters

$consumerService

\ZBateson\MailMimeParser\Header\Consumer\ConsumerService

Returns

\ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer

Overridden to assign comments to $this->comments, and the DateTime to $this->date.

setParseHeaderValue(\ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer $consumer) 

The default implementation assigns the returned value to $this->part.

inherited_from \ZBateson\MailMimeParser\Header\ParameterHeader::setParseHeaderValue()

Parameters

$consumer

\ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer

Calls the consumer and assigns the parsed parts to member variables.

setParseHeaderValue(\ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer $consumer) 
Inherited

The default implementation assigns the returned value to $this->part.

Parameters

$consumer

\ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer

 Properties

 

an array of comments in the header.

$comments : array<mixed,string>

Default

array()
 

the date/time stamp in the header.

$date : \ZBateson\MailMimeParser\Header\DateTime

Default

 

the name of the header

$name : string

Default

 

key map of lower-case parameter names and associated ParameterParts.

$parameters : array<mixed,\ZBateson\MailMimeParser\Header\Part\ParameterPart>

Default

array()
 

the header's parts (as returned from the consumer)

$parts : array<mixed,\ZBateson\MailMimeParser\Header\Part\HeaderPart>

Default

 

the raw value

$rawValue : string

Default