-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmailMessage.php
139 lines (124 loc) · 2.63 KB
/
EmailMessage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
class EmailMessage
{
private $to;
private array $headers;
private string $subject;
private string $body;
/**
* @return string|array|null
*/
public function getTo()
{
return $this->to;
}
/**
* @param string|array|null
*/
public function setTo($to): void
{
$this->to = $to;
}
/**
* @return string|null
*/
public function getFrom(): ?string
{
foreach ($this->headers as $header) {
if (preg_match('/From: (.+)/i', $header, $matches) && $matches[1]) {
return $matches[1];
}
}
return null;
}
/**
* @return array
*/
public function getHeaders(): array
{
return $this->headers;
}
/**
* @param array $headers
*/
public function setHeaders(array $headers): void
{
$this->headers = $headers;
}
/**
* @return string|null
*/
public function getBcc(): ?string
{
foreach ($this->headers as $header) {
if (preg_match('/BCC: (.+)/i', $header, $matches) && $matches[1]) {
return $matches[1];
}
}
return null;
}
/**
* @return string|null
*/
public function getCc(): ?string
{
foreach ($this->headers as $header) {
if (preg_match('/CC: (.+)/i', $header, $matches) && $matches[1]) {
return $matches[1];
}
}
return null;
}
/**
* @return string|null
*/
public function getContentType(): ?string
{
foreach ($this->headers as $header) {
if (preg_match('/Content-Type: (.+)/i', $header, $matches) && $matches[1]) {
return $matches[1];
}
}
return null;
}
/**
* @return string|null
*/
public function getReplyTo(): ?string
{
foreach ($this->headers as $header) {
if (preg_match('/Reply-To: (.+)/i', $header, $matches) && $matches[1]) {
return $matches[1];
}
}
return null;
}
/**
* @return string
*/
public function getSubject(): string
{
return $this->subject;
}
/**
* @param string $subject
*/
public function setSubject(string $subject): void
{
$this->subject = $subject;
}
/**
* @return string
*/
public function getBody(): string
{
return $this->body;
}
/**
* @param string $body
*/
public function setBody(string $body): void
{
$this->body = $body;
}
}