Copied!

Holds extra information about a parsed Received header part, for FROM and BY parts, namely: ehlo name, hostname, and address.

The parsed parts would be mapped as follows:

FROM ehlo name (hostname [address]), for example: FROM computer (domain.com [1.2.3.4]) would contain "computer" for getEhloName(), domain.com for getHostname and 1.2.3.4 for getAddress().

This doesn't change if the ehlo name is an address, it is still returned in getEhloName(), and not in getAddress(). Additionally square brackets are not stripped from getEhloName() if its an address. For example: "FROM [1.2.3.4]" would return "[1.2.3.4]" in a call to getEhloName().

For further information on how the header's parsed, check the documentation for {@see \ZBateson\MailMimeParser\Header\Consumer\Received\DomainConsumer}.

CloneableInstantiable
Constants
public ZBateson\MailMimeParser\Header\Part\MimeLiteralPart::MIME_PART_PATTERN = '=\?[^?=]+\?[QBqb]\?[^\?]+\?='
 
  • var string regex pattern matching a mime-encoded part
public ZBateson\MailMimeParser\Header\Part\MimeLiteralPart::MIME_PART_PATTERN_NO_QUOTES = '=\?[^\?=]+\?[QBqb]\?[^\?"]+\?='
 
  • var string regex pattern used when parsing parameterized headers
Methods
public __construct(ZBateson\MbWrapper\MbWrapper $charsetConverter, $name, $value, $ehloName = NULL, $hostname = NULL, $address = NULL)
 
  • param string $name
  • param string $value
  • param string $ehloName
  • param string $hostname
  • param string $address
public ZBateson\MailMimeParser\Header\Part\HeaderPart::__toString() : string
 

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

  • return string the value
public getAddress() : ?string
 

Returns the address of the server, or whatever string that looks like an address in the address position when parsing (but never a hostname).

public getEhloName()
 

Returns the name used to identify the server in the first part of the extended-domain line.

Note that this is not necessarily the name used in the EHLO line to an SMTP server, since implementations differ so much, not much can be guaranteed except the position it was parsed in.

  • return string|null The name
public getHostname()
 

Returns the hostname of the server, or whatever string in the hostname position when parsing (but never an address).

  • return string|null
public ZBateson\MailMimeParser\Header\Part\ParameterPart::getLanguage()
 

Returns the RFC-1766 (or subset) language tag, if the parameter is a split RFC-2231 part with a language tag set.

  • return string the language
public ZBateson\MailMimeParser\Header\Part\MimeLiteralPart::getLanguageArray()
 

Returns an array of parts mapped to languages in the header value, for instance the string:

'Hello and =?UTF-8fr-be?Q?bonjour_?= =?UTF-8it?Q?mi amici?=. Welcome!'

Would be mapped in the returned array as follows:

[
    0 => [ 'lang' => null, 'value' => 'Hello and ' ],
    1 => [ 'lang' => 'fr-be', 'value' => 'bonjour ' ],
    3 => [ 'lang' => 'it', 'value' => 'mi amici' ],
    4 => [ 'lang' => null, 'value' => ' Welcome!' ]
]
  • return string[][]
public ZBateson\MailMimeParser\Header\Part\ParameterPart::getName()
 

Returns the name of the parameter.

  • return string The name.
public ZBateson\MailMimeParser\Header\Part\HeaderPart::getValue() : ?string
 

Returns the part's value.

  • return ?string the value of the part
public ZBateson\MailMimeParser\Header\Part\MimeLiteralPart::ignoreSpacesAfter() : bool
 

Returns true if spaces before this part should be ignored.

Overridden to return $this->canIgnoreSpacesAfter which is setup in the constructor.

public ZBateson\MailMimeParser\Header\Part\MimeLiteralPart::ignoreSpacesBefore() : bool
 

Returns true if spaces before this part should be ignored.

Overridden to return $this->canIgnoreSpacesBefore which is setup in the constructor.

Properties
protected $address = NULL
 
  • var string The address.
protected ZBateson\MailMimeParser\Header\Part\MimeLiteralPart::$canIgnoreSpacesAfter = false
 
  • var bool set to true to ignore spaces after this part
protected ZBateson\MailMimeParser\Header\Part\MimeLiteralPart::$canIgnoreSpacesBefore = false
 
  • var bool set to true to ignore spaces before this part
protected ZBateson\MailMimeParser\Header\Part\HeaderPart::$charsetConverter = NULL
 
  • var \MbWrapper $charsetConverter the charset converter used for converting strings in HeaderPart::convertEncoding
protected $ehloName = NULL
 
  • var string The name used to identify the server in the EHLO line.
protected $hostname = NULL
 
  • var string The hostname.
protected ZBateson\MailMimeParser\Header\Part\ParameterPart::$language = NULL
 
  • var string the RFC-1766 language tag if set.
protected ZBateson\MailMimeParser\Header\Part\MimeLiteralPart::$languages = []
 
  • var array maintains an array mapping rfc1766 language tags to parts of text in the value. Each array element is an array containing two elements, one with key 'lang', and another with key 'value'.
protected ZBateson\MailMimeParser\Header\Part\ParameterPart::$name = NULL
 
  • var string the name of the parameter
protected ZBateson\MailMimeParser\Header\Part\HeaderPart::$value = NULL
 
  • var string the value of the part
Methods
protected ZBateson\MailMimeParser\Header\Part\MimeLiteralPart::addToLanguage(string $part, ?string $language = NULL) : self
 

Adds the passed part into the languages array with the given language.

protected ZBateson\MailMimeParser\Header\Part\HeaderPart::convertEncoding(string $str, string $from = 'ISO-8859-1', bool $force = false) : string
 

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

The method does nothing if the passed $from charset is UTF-8 already, or if $force is set to false and mb_check_encoding for $str returns true for 'UTF-8'.

  • return string utf-8 string
protected ZBateson\MailMimeParser\Header\Part\MimeLiteralPart::decodeMime(string $value) : string
 

Finds and replaces mime parts with their values.

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.

© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration