The "invalid remote specification" error indicates that there is an issue with the format of the server address in your code.
In your code, the server address is specified as '{arcnetoff65.ru:143/imap/starttls}INBOX'. However, the correct format for the server address should be '{hostname:port/protocol}mailbox'.
To fix the error, you should remove the protocol 'starttls' from the server address, as it should be specified separately in the imap_open function. The corrected server address should look like this: '{arcnetoff65.ru:143}INBOX'.
Here is the corrected code:
```php
/* Конфигурация */
// Параметры сервера
$server = '{arcnetoff65.ru:143}INBOX';
// Учетные данные
$username = 'rucap@arcnetoff65.ru';
$password = 'i3tqkwHxZ2taTBw';
/* Установка соединения */
// Подключение к серверу
$inbox = imap_open($server, $username, $password);
if (!$inbox) {
die('Не удалось установить соединение с сервером: ' . imap_last_error());
}
/* Работа с почтой */
// Получение списка всех папок
$mailboxes = imap_listmailbox($inbox, $server, '*');
if (!$mailboxes) {
die('Не удалось получить список папок: ' . imap_last_error());
}
// Получение количества непрочитанных сообщений во входящих
$unread = imap_search($inbox, 'UNSEEN');
if ($unread === false) {
die('Не удалось получить количество непрочитанных сообщений: ' . imap_last_error());
}
echo 'Количество непрочитанных сообщений: ' . count($unread);
/* Закрытие соединения */
imap_close($inbox);
```