1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
mailboxconnecting.php
См. документацию.
1<?php
2
3namespace Bitrix\Mail\Controller;
4
5use Bitrix\Mail\Helper\Mailbox;
6use Bitrix\Mail\Helper\Mailbox\MailboxConnector;
7use Bitrix\Mail\MailServicesTable;
8use Bitrix\Main\Engine\Controller;
9use Bitrix\Main\Engine\UrlManager;
10use Bitrix\Main\Error;
11use Bitrix\Main\Loader;
12use Bitrix\Mail\Helper\OAuth;
13use Bitrix\Main\Localization\Loc;
14use Bitrix\Main\Web\Uri;
15
23{
30 public function getUrlOauthAction(string $serviceName, string $type = OAuth::WEB_TYPE): string
31 {
32 if (!Loader::includeModule('mail'))
33 {
34 $this->addError(new Error(Loc::getMessage('MAIL_MAILBOX_CONNECTING_ERROR_MAIL_MODULE_IS_NOT_INSTALLED')));
35 return '';
36 }
37
38 $oauthHelper = OAuth::getInstance($serviceName);
39
40 if (!$oauthHelper)
41 {
42 $this->addError(new Error(Loc::getMessage('MAIL_MAILBOX_CONNECTING_ERROR_MAIL_MODULE_OAUTH_SERVICE_IS_NOT_CONFIGURED')));
43 return false;
44 }
45
46 return $oauthHelper->getUrl($type);
47 }
48
53 public function getServicesAction(): array
54 {
55 if (!Loader::includeModule('mail'))
56 {
57 $this->addError(new Error(Loc::getMessage('MAIL_MAILBOX_CONNECTING_ERROR_MAIL_MODULE_IS_NOT_INSTALLED')));
58 return [];
59 }
60
61 $services = Mailbox::getServices();
62
63 foreach ($services as &$service)
64 {
65 if (
66 MailServicesTable::getOAuthHelper(['NAME' => $service['name']]) instanceof OAuth
68 )
69 {
70 $service['oauthMode'] = true;
71 }
72 else
73 {
74 $service['oauthMode'] = false;
75 }
76 }
77
78 return $services;
79 }
80
81 public function getConnectionUrlAction(): string
82 {
83 $uri = new Uri(UrlManager::getInstance()->getHostUrl().'/bitrix/tools/mobile_oauth.php');
84 return $uri->getLocator();
85 }
86
87 public function connectMailboxAction(
88 string $login = '',
89 string $password = '',
90 int $serviceId = 0,
91 string $server = '',
92 int $port = 993,
93 bool $ssl = true,
94 string $storageOauthUid = '',
95 bool $syncAfterConnection = true,
96 bool $useSmtp = true,
97 string $serverSmtp = '',
98 int $portSmtp = 587,
99 bool $sslSmtp = true,
100 string $loginSmtp = '',
101 string $passwordSMTP = ''
102 ): array
103 {
104 if (!Loader::includeModule('mail'))
105 {
106 $this->addError(new Error(Loc::getMessage('MAIL_MAILBOX_CONNECTING_ERROR_MAIL_MODULE_IS_NOT_INSTALLED')));
107 return [];
108 }
109
110 $mailboxConnector = new MailboxConnector();
111 $result = $mailboxConnector->connectMailbox($login, $password, $serviceId, $server, $port, $ssl, $storageOauthUid, $syncAfterConnection, $useSmtp, $serverSmtp, $portSmtp, $sslSmtp, $loginSmtp, $passwordSMTP);
112 $this->addErrors($mailboxConnector->getErrors());
113
114 return $result;
115 }
116}
$type
Определения options.php:106
$login
Определения change_password.php:8
getUrlOauthAction(string $serviceName, string $type=OAuth::WEB_TYPE)
Определения mailboxconnecting.php:30
connectMailboxAction(string $login='', string $password='', int $serviceId=0, string $server='', int $port=993, bool $ssl=true, string $storageOauthUid='', bool $syncAfterConnection=true, bool $useSmtp=true, string $serverSmtp='', int $portSmtp=587, bool $sslSmtp=true, string $loginSmtp='', string $passwordSMTP='')
Определения mailboxconnecting.php:87
static isOauthSmtpEnabled(string $serviceName)
Определения mailboxconnector.php:200
static getOAuthHelper($data)
Определения mailservices.php:218
static getInstance()
Определения application.php:98
Определения error.php:15
Определения uri.php:17
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
if(file_exists($_SERVER['DOCUMENT_ROOT'] . "/urlrewrite.php")) $uri
Определения urlrewrite.php:61
$password
Определения mysql_to_pgsql.php:34
$service
Определения payment.php:18