refactor: use custom imap client

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-05-08 00:16:43 -04:00
parent a728aeb11c
commit a8764747fd
179 changed files with 6782 additions and 5907 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -9,9 +9,9 @@ declare(strict_types=1);
namespace KTXM\ProviderImap\Service\Remote;
use Gricob\IMAP\Client;
use KTXC\Server;
use KTXC\Logger\PlainFileLogger;
use KTXM\ProviderImap\Client\Client;
use KTXM\ProviderImap\Providers\Service;
/**
@@ -23,10 +23,7 @@ use KTXM\ProviderImap\Providers\Service;
class RemoteService
{
/**
* Build a fully-configured IMAP client from a Service's location and identity.
*
* Handles STARTTLS: connects on plain TCP, sends STARTTLS, upgrades to TLS,
* then authenticates — all before returning the client.
* Build and bootstrap a fully-configured IMAP client from a Service.
*/
public static function freshClient(Service $service): Client
{
@@ -40,14 +37,13 @@ class RemoteService
$logger = new PlainFileLogger($logDir . '/imap', $service->identifier());
}
$client = Client::create($location->toConfiguration(), $logger);
$client->connect();
$config = $location->toConnectionConfig(
$identity?->getIdentity(),
$identity?->getSecret(),
);
if ($location->getEncryption() === 'starttls') {
$client->startTls();
}
$client->logIn($identity->getIdentity(), $identity->getSecret());
$client = new Client(logger: $logger);
$client->connect($config);
return $client;
}