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

View File

@@ -9,7 +9,8 @@ declare(strict_types=1);
namespace KTXM\ProviderImap\Providers;
use Gricob\IMAP\Configuration;
use KTXM\ProviderImap\Client\ConnectionConfig;
use KTXM\ProviderImap\Client\ConnectionSecurity;
use KTXF\Resource\Provider\ResourceServiceLocationInterface;
/**
@@ -101,34 +102,28 @@ class ServiceLocation implements ResourceServiceLocationInterface
public function getAllowSelfSigned(): bool { return $this->allowSelfSigned; }
public function setAllowSelfSigned(bool $v): void { $this->allowSelfSigned = $v; }
// ── gricob helper ───────────────────────────────────────────────────────
// ── Client helpers ───────────────────────────────────────────────────────
/**
* Build a Gricob IMAP Configuration from this location.
*
* gricob passes the transport directly to stream_socket_client:
* 'ssl' → ssl://host:port (implicit TLS, port 993)
* 'tcp' → tcp://host:port (plain TCP; STARTTLS negotiation is not
* supported by gricob, so starttls/none both
* use plain TCP)
* Build a standalone IMAP client ConnectionConfig from this location.
*/
public function toConfiguration(): Configuration
public function toConnectionConfig(?string $username = null, ?string $password = null): ConnectionConfig
{
// Map our encryption label to a stream_socket_client transport.
// gricob has no STARTTLS negotiation, so starttls falls back to tcp.
$transport = match ($this->encryption) {
'ssl', 'tls' => 'ssl',
default => 'tcp', // starttls, none
$security = match ($this->encryption) {
'ssl', 'tls' => ConnectionSecurity::Tls,
'starttls' => ConnectionSecurity::StartTls,
default => ConnectionSecurity::Plain,
};
return new Configuration(
transport: $transport,
host: $this->host,
port: $this->port,
verifyPeer: $this->verifyPeer,
verifyPeerName: $this->verifyPeerName,
allowSelfSigned: $this->allowSelfSigned,
useUid: true,
return new ConnectionConfig(
host: $this->host,
port: $this->port,
security: $security,
username: $username,
password: $password,
verifyPeer: $this->verifyPeer,
verifyPeerName: $this->verifyPeerName,
allowSelfSigned: $this->allowSelfSigned,
);
}
}