1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
config.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\Mail\Smtp;
4
5use Bitrix\Main;
6use Bitrix\Mail;
7
8class 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
61
62 public function __construct(array $params = null)
63 {
64 if (!empty($params))
65 {
66 foreach ($params as $name => $value)
67 {
68 $setter = sprintf('set%s', $name);
69 if (is_callable(array($this, $setter)))
70 $this->$setter($value);
71 }
72 }
73 }
74
75 public function setFrom($from)
76 {
77 $this->from = $from;
78 return $this;
79 }
80
81 public function setHost($host)
82 {
83 $this->host = $host;
84 return $this;
85 }
86
87 public function setPort($port)
88 {
89 $this->port = (int) $port;
90 return $this;
91 }
92
93 public function setProtocol($protocol)
94 {
95 $this->protocol = $protocol;
96 return $this;
97 }
98
99 public function setLogin($login)
100 {
101 $this->login = $login;
102 return $this;
103 }
104
105 public function setPassword($password)
106 {
107 $this->password = $password;
108 return $this;
109 }
110
118 public function setIsOauth($isOauth): self
119 {
120 $this->isOauth = (bool)$isOauth;
121 return $this;
122 }
123
124 public function getFrom()
125 {
126 return $this->from;
127 }
128
129 public function getHost()
130 {
131 return $this->host;
132 }
133
134 public function getPort()
135 {
136 return $this->port;
137 }
138
139 public function getProtocol()
140 {
141 return $this->protocol;
142 }
143
144 public function getLogin()
145 {
146 return $this->login;
147 }
148
149 public function getPassword()
150 {
151 return $this->password;
152 }
153
159 public function getIsOauth(): bool
160 {
161 return $this->isOauth;
162 }
163
165 {
166 return $this->cloudOAuthRefreshData;
167 }
168
170 {
171 $this->cloudOAuthRefreshData = $data;
172
173 return $this;
174 }
175
176 public static function canCheck()
177 {
178 return Main\Loader::includeModule('mail') && class_exists('Bitrix\Mail\Smtp');
179 }
180
181 public function check(&$error = null, Main\ErrorCollection &$errors = null)
182 {
183 $error = null;
184 $errors = null;
185
186 if (!$this->canCheck())
187 {
188 return null;
189 }
190
192 {
193 // Private addresses can't be used in the cloud
194 $ip = Main\Web\IpAddress::createByName($this->host);
195 if ($ip->isPrivate())
196 {
197 $error = 'SMTP server address is invalid';
199 return false;
200 }
201 }
202
203 $client = new Mail\Smtp(
204 $this->host,
205 $this->port,
206 ('smtps' === $this->protocol || ('smtp' !== $this->protocol && 465 === $this->port)),
207 true,
208 $this->login,
209 $this->password
210 );
211 if (method_exists($client, 'setIsOauth'))
212 {
213 $client->setIsOauth($this->getIsOauth());
214 }
215
216 if (!$client->authenticate($error))
217 {
218 $errors = $client->getErrors();
219 return false;
220 }
221
222 return true;
223 }
224
225}
$login
Определения change_password.php:8
Определения smtp.php:12
Определения error.php:15
static includeModule($moduleName)
Определения loader.php:67
setPort($port)
Определения config.php:87
getPassword()
Определения config.php:149
static canCheck()
Определения config.php:176
CloudOAuthRefreshData $cloudOAuthRefreshData
Определения config.php:60
setHost($host)
Определения config.php:81
setIsOauth($isOauth)
Определения config.php:118
__construct(array $params=null)
Определения config.php:62
getCloudOAuthRefreshData()
Определения config.php:164
setPassword($password)
Определения config.php:105
bool $isOauth
Определения config.php:58
setCloudOAuthRefreshData(?CloudOAuthRefreshData $data)
Определения config.php:169
setFrom($from)
Определения config.php:75
check(&$error=null, Main\ErrorCollection &$errors=null)
Определения config.php:181
setLogin($login)
Определения config.php:99
getProtocol()
Определения config.php:139
setProtocol($protocol)
Определения config.php:93
static isModuleInstalled($moduleName)
Определения modulemanager.php:125
static createByName($name)
Определения ipaddress.php:32
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$protocol
Определения .description.php:9
$errors
Определения iblock_catalog_edit.php:74
$name
Определения menu_edit.php:35
$password
Определения mysql_to_pgsql.php:34
$host
Определения mysql_to_pgsql.php:32
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$error
Определения subscription_card_product.php:20