1 | <?php |
||
7 | class EmailMessage |
||
8 | { |
||
9 | /** @var array array */ |
||
10 | protected $headers = []; |
||
11 | |||
12 | /** @var string */ |
||
13 | protected $subject = ''; |
||
14 | |||
15 | /** @var string */ |
||
16 | protected $body = ''; |
||
17 | |||
18 | 1 | public function getHeaders(): array |
|
22 | |||
23 | 5 | public function from(string $email, string $name = null) |
|
29 | |||
30 | 1 | public function getFrom(): array |
|
31 | { |
||
32 | 1 | return $this->headers['From'] ?? []; |
|
33 | } |
||
34 | |||
35 | 1 | public function sender(string $email, string $name = null) |
|
41 | |||
42 | public function getSender(): string |
||
46 | |||
47 | 1 | public function replyTo(string $email, string $name = null) |
|
53 | |||
54 | public function getReplyTo(): array |
||
58 | |||
59 | 4 | public function to(string $email, string $name = null) |
|
65 | |||
66 | 4 | public function getTo(): array |
|
70 | |||
71 | 1 | public function cc(string $email, string $name = null) |
|
77 | |||
78 | public function getCc(): array |
||
82 | |||
83 | 1 | public function bcc(string $email, string $name = null) |
|
89 | |||
90 | public function getBcc(): array |
||
94 | |||
95 | 5 | public function subject(string $subject) |
|
101 | |||
102 | 1 | public function getSubject(): string |
|
106 | |||
107 | 1 | public function textBody(string $textBody) |
|
113 | |||
114 | 4 | public function htmlBody(string $htmlBody) |
|
115 | { |
||
116 | 4 | $this->body = $htmlBody; |
|
117 | 4 | $this->headers['MIME-Version'] = '1.0'; |
|
118 | 4 | $this->headers['Content-type'] = 'text/html; charset=utf-8'; |
|
119 | |||
120 | 4 | return $this; |
|
121 | } |
||
122 | |||
123 | 2 | public function getBody(): string |
|
127 | |||
128 | 5 | private function createAddress(string $email, ?string $name): string |
|
132 | } |
||
133 |