Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
part.php
1
<?php
8
namespace
Bitrix\Main\Mail
;
9
14
class
Part
15
{
17
protected
$headers
= [];
18
20
protected
$body
=
''
;
21
23
protected
$eol
;
24
28
public
function
__construct
()
29
{
30
$this->eol = Mail::getMailEol();
31
}
32
38
public
function
getEol
()
39
{
40
return
$this->eol
;
41
}
42
49
public
function
setEol
(
$eol
)
50
{
51
$this->eol =
$eol
;
52
return
$this;
53
}
54
62
public
function
addHeader
($name, $value)
63
{
64
$this->headers[$name] = $value;
65
return
$this;
66
}
67
74
public
function
setHeaders
(array
$headers
)
75
{
76
$this->headers = [];
77
foreach
(
$headers
as $name => $value)
78
{
79
$this->
addHeader
($name, $value);
80
}
81
return
$this;
82
}
83
89
public
function
getHeaders
()
90
{
91
return
$this->headers
;
92
}
93
100
public
function
getHeader
($name)
101
{
102
return
$this->headers[$name] ??
null
;
103
}
104
111
public
function
setBody
(
$body
)
112
{
113
$this->body =
$body
;
114
return
$this;
115
}
116
122
public
function
getBody
()
123
{
124
return
$this->body
;
125
}
126
132
public
function
toStringBody
()
133
{
134
return
$this->
splitBody
($this->body) . $this->eol .
$this->eol
;
135
}
136
142
public
function
toStringHeaders
()
143
{
144
$result =
''
;
145
foreach
($this->headers as $name => $value)
146
{
147
$result .= $name .
': '
. $value .
$this->eol
;
148
}
149
150
return
$result ? $result :
''
;
151
}
152
158
public
function
toString
()
159
{
160
return
$this->
toStringHeaders
() . $this->eol . $this->
toStringBody
();
161
}
162
168
public
function
__toString
()
169
{
170
return
$this->
toString
();
171
}
172
173
protected
function
splitBody
(&
$body
)
174
{
175
if
($this->
getHeader
(
'Content-Transfer-Encoding'
) ===
'base64'
)
176
{
177
return
rtrim(chunk_split(base64_encode(
$body
), 76, $this->eol));
178
}
179
elseif ($this->
getHeader
(
'Content-Transfer-Encoding'
) ===
'quoted-printable'
)
180
{
181
return
str_replace(
182
$this->eol !==
"\r\n"
?
"=\r\n"
:
''
,
183
'='
.
$this->eol
,
184
quoted_printable_encode(
$body
)
185
);
186
}
187
else
188
{
189
return
preg_replace(
190
'/(.{1,990})(?:\s|$)|(.{990})/S'
,
191
'$1$2'
. $this->eol,
192
$body
193
);
194
}
195
}
196
}
Bitrix\Main\Mail\Part
Definition
part.php:15
Bitrix\Main\Mail\Part\setBody
setBody($body)
Definition
part.php:111
Bitrix\Main\Mail\Part\__construct
__construct()
Definition
part.php:28
Bitrix\Main\Mail\Part\getHeaders
getHeaders()
Definition
part.php:89
Bitrix\Main\Mail\Part\addHeader
addHeader($name, $value)
Definition
part.php:62
Bitrix\Main\Mail\Part\$body
$body
Definition
part.php:20
Bitrix\Main\Mail\Part\$headers
$headers
Definition
part.php:17
Bitrix\Main\Mail\Part\toString
toString()
Definition
part.php:158
Bitrix\Main\Mail\Part\getHeader
getHeader($name)
Definition
part.php:100
Bitrix\Main\Mail\Part\__toString
__toString()
Definition
part.php:168
Bitrix\Main\Mail\Part\toStringHeaders
toStringHeaders()
Definition
part.php:142
Bitrix\Main\Mail\Part\getEol
getEol()
Definition
part.php:38
Bitrix\Main\Mail\Part\$eol
$eol
Definition
part.php:23
Bitrix\Main\Mail\Part\setHeaders
setHeaders(array $headers)
Definition
part.php:74
Bitrix\Main\Mail\Part\getBody
getBody()
Definition
part.php:122
Bitrix\Main\Mail\Part\setEol
setEol($eol)
Definition
part.php:49
Bitrix\Main\Mail\Part\toStringBody
toStringBody()
Definition
part.php:132
Bitrix\Main\Mail\Part\splitBody
splitBody(&$body)
Definition
part.php:173
Bitrix\Main\Mail
Definition
address.php:8
modules
main
lib
mail
part.php
Создано системой
1.10.0