1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the ZBateson\MailMimeParser project. |
4
|
|
|
* |
5
|
|
|
* @license http://opensource.org/licenses/bsd-license.php BSD |
6
|
|
|
*/ |
7
|
|
|
namespace ZBateson\MailMimeParser\Header\Part; |
8
|
|
|
|
9
|
|
|
use ZBateson\StreamDecorators\Util\CharsetConverter; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Holds extra information about a parsed Received header part, for FROM and BY |
13
|
|
|
* parts, namely: ehlo name, hostname, and address. |
14
|
|
|
* |
15
|
|
|
* The parsed parts would be mapped as follows: |
16
|
|
|
* |
17
|
|
|
* FROM ehlo name (hostname [address]), for example: FROM computer (domain.com |
18
|
|
|
* [1.2.3.4]) would contain "computer" for getEhloName(), domain.com for |
19
|
|
|
* getHostname and 1.2.3.4 for getAddress(). |
20
|
|
|
* |
21
|
|
|
* This doesn't change if the ehlo name is an address, it is still returned in |
22
|
|
|
* getEhloName(), and not in getAddress(). Additionally square brackets are not |
23
|
|
|
* stripped from getEhloName() if its an address. For example: "FROM [1.2.3.4]" |
24
|
|
|
* would return "[1.2.3.4]" in a call to getEhloName(). |
25
|
|
|
* |
26
|
|
|
* For further information on how the header's parsed, check the documentation |
27
|
|
|
* for {@see \ZBateson\MailMimeParser\Header\Consumer\Received\DomainConsumer}. |
28
|
|
|
* |
29
|
|
|
* @author Zaahid Bateson |
30
|
|
|
*/ |
31
|
|
|
class ReceivedDomainPart extends ReceivedPart |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* @var string The name used to identify the server in the EHLO line. |
35
|
|
|
*/ |
36
|
|
|
protected $ehloName; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var string The hostname. |
40
|
|
|
*/ |
41
|
|
|
protected $hostname; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var string The address. |
45
|
|
|
*/ |
46
|
|
|
protected $address; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* |
50
|
|
|
* @param CharsetConverter $charsetConverter |
51
|
|
|
* @param string $name |
52
|
|
|
* @param string $value |
53
|
|
|
* @param string $ehloName |
54
|
|
|
* @param string $hostname |
55
|
|
|
* @param string $address |
56
|
|
|
*/ |
57
|
|
|
public function __construct(CharsetConverter $charsetConverter, $name, $value, $ehloName = null, $hostname = null, $address = null) { |
58
|
|
|
parent::__construct($charsetConverter, $name, $value); |
59
|
|
|
$this->ehloName = $ehloName; |
60
|
|
|
$this->hostname = $hostname; |
61
|
|
|
$this->address = $address; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Returns the name used to identify the server in the first part of the |
66
|
|
|
* extended-domain line. Note that this is not necessarily the name used in |
67
|
|
|
* the EHLO line to an SMTP server, since implementations differ so much, |
68
|
|
|
* not much can be guaranteed except the position it was parsed in. |
69
|
|
|
* |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
public function getEhloName() |
73
|
|
|
{ |
74
|
|
|
return $this->ehloName; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Returns the hostname of the server, or whatever string in the hostname |
79
|
|
|
* position when parsing (but never an address). |
80
|
|
|
* |
81
|
|
|
* @return string |
82
|
|
|
*/ |
83
|
|
|
public function getHostname() |
84
|
|
|
{ |
85
|
|
|
return $this->hostname; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Returns the address of the server, or whatever string that looks like an |
90
|
|
|
* address in the address position when parsing (but never a hostname). |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getAddress() |
95
|
|
|
{ |
96
|
|
|
return $this->address; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|