Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
config.php
1
<?php
2
3
namespace
Bitrix\Main\Mail\Smtp
;
4
5
use \Bitrix\Main;
6
use \Bitrix\Mail;
7
8
class
Config
9
{
10
16
protected
$from
;
17
23
protected
$host
;
24
30
protected
$port
;
31
37
protected
$protocol
;
38
44
protected
$login
;
45
51
protected
$password
;
52
58
protected
bool
$isOauth
=
false
;
59
60
public
function
__construct
(array $params =
null
)
61
{
62
if
(!empty($params))
63
{
64
foreach
($params as $name => $value)
65
{
66
$setter = sprintf(
'set%s'
, $name);
67
if
(is_callable(array($this, $setter)))
68
$this->$setter($value);
69
}
70
}
71
}
72
73
public
function
setFrom
($from)
74
{
75
$this->from =
$from
;
76
return
$this;
77
}
78
79
public
function
setHost
($host)
80
{
81
$this->host =
$host
;
82
return
$this;
83
}
84
85
public
function
setPort
($port)
86
{
87
$this->port = (int)
$port
;
88
return
$this;
89
}
90
91
public
function
setProtocol
($protocol)
92
{
93
$this->protocol =
$protocol
;
94
return
$this;
95
}
96
97
public
function
setLogin
($login)
98
{
99
$this->login =
$login
;
100
return
$this;
101
}
102
103
public
function
setPassword
($password)
104
{
105
$this->password =
$password
;
106
return
$this;
107
}
108
116
public
function
setIsOauth
($isOauth): self
117
{
118
$this->isOauth = (bool)$isOauth;
119
return
$this;
120
}
121
122
public
function
getFrom
()
123
{
124
return
$this->from;
125
}
126
127
public
function
getHost
()
128
{
129
return
$this->host;
130
}
131
132
public
function
getPort
()
133
{
134
return
$this->port;
135
}
136
137
public
function
getProtocol
()
138
{
139
return
$this->protocol;
140
}
141
142
public
function
getLogin
()
143
{
144
return
$this->login;
145
}
146
147
public
function
getPassword
()
148
{
149
return
$this->password;
150
}
151
157
public
function
getIsOauth
(): bool
158
{
159
return
$this->isOauth;
160
}
161
162
public
static
function
canCheck
()
163
{
164
return
Main\Loader::includeModule(
'mail'
) && class_exists(
'Bitrix\Mail\Smtp'
);
165
}
166
167
public
function
check
(&$error =
null
, Main\
ErrorCollection
&$errors =
null
)
168
{
169
$error =
null
;
170
$errors =
null
;
171
172
if
(!$this->
canCheck
())
173
{
174
return
null
;
175
}
176
177
if
(Main\
ModuleManager::isModuleInstalled
(
'bitrix24'
))
178
{
179
// Private addresses can't be used in the cloud
180
$ip = Main\Web\IpAddress::createByName($this->host);
181
if
($ip->isPrivate())
182
{
183
$error =
'SMTP server address is invalid'
;
184
$errors =
new
Main\ErrorCollection
([
new
Main\
Error
($error)]);
185
return
false
;
186
}
187
}
188
189
$client =
new
Mail\Smtp(
190
$this->host,
191
$this->port,
192
(
'smtps'
=== $this->protocol || (
'smtp'
!== $this->protocol && 465 === $this->port)),
193
true
,
194
$this->login,
195
$this->password
196
);
197
if
(method_exists($client,
'setIsOauth'
))
198
{
199
$client->setIsOauth($this->
getIsOauth
());
200
}
201
202
if
(!$client->authenticate($error))
203
{
204
$errors = $client->getErrors();
205
return
false
;
206
}
207
208
return
true
;
209
}
210
211
}
Bitrix\Main\ErrorCollection
Definition
errorcollection.php:14
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Mail\Smtp\Config\setPort
setPort($port)
Definition
config.php:85
Bitrix\Main\Mail\Smtp\Config\getPassword
getPassword()
Definition
config.php:147
Bitrix\Main\Mail\Smtp\Config\$from
$from
Definition
config.php:16
Bitrix\Main\Mail\Smtp\Config\canCheck
static canCheck()
Definition
config.php:162
Bitrix\Main\Mail\Smtp\Config\getFrom
getFrom()
Definition
config.php:122
Bitrix\Main\Mail\Smtp\Config\setHost
setHost($host)
Definition
config.php:79
Bitrix\Main\Mail\Smtp\Config\getHost
getHost()
Definition
config.php:127
Bitrix\Main\Mail\Smtp\Config\setIsOauth
setIsOauth($isOauth)
Definition
config.php:116
Bitrix\Main\Mail\Smtp\Config\__construct
__construct(array $params=null)
Definition
config.php:60
Bitrix\Main\Mail\Smtp\Config\setPassword
setPassword($password)
Definition
config.php:103
Bitrix\Main\Mail\Smtp\Config\$isOauth
bool $isOauth
Definition
config.php:58
Bitrix\Main\Mail\Smtp\Config\$password
$password
Definition
config.php:51
Bitrix\Main\Mail\Smtp\Config\$host
$host
Definition
config.php:23
Bitrix\Main\Mail\Smtp\Config\setFrom
setFrom($from)
Definition
config.php:73
Bitrix\Main\Mail\Smtp\Config\getLogin
getLogin()
Definition
config.php:142
Bitrix\Main\Mail\Smtp\Config\check
check(&$error=null, Main\ErrorCollection &$errors=null)
Definition
config.php:167
Bitrix\Main\Mail\Smtp\Config\$port
$port
Definition
config.php:30
Bitrix\Main\Mail\Smtp\Config\setLogin
setLogin($login)
Definition
config.php:97
Bitrix\Main\Mail\Smtp\Config\getProtocol
getProtocol()
Definition
config.php:137
Bitrix\Main\Mail\Smtp\Config\$protocol
$protocol
Definition
config.php:37
Bitrix\Main\Mail\Smtp\Config\setProtocol
setProtocol($protocol)
Definition
config.php:91
Bitrix\Main\Mail\Smtp\Config\getIsOauth
getIsOauth()
Definition
config.php:157
Bitrix\Main\Mail\Smtp\Config\$login
$login
Definition
config.php:44
Bitrix\Main\Mail\Smtp\Config\getPort
getPort()
Definition
config.php:132
Bitrix\Main\ModuleManager\isModuleInstalled
static isModuleInstalled($moduleName)
Definition
modulemanager.php:67
Bitrix\Main\Config
Definition
configuration.php:2
Bitrix\Main\Mail\Smtp
Definition
config.php:3
modules
main
lib
mail
smtp
config.php
Создано системой
1.10.0