generated from Nodarx/template
refactor: use custom imap client
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user