refactor: smtp client

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-06-23 16:51:54 -04:00
parent ad6b7c5eba
commit 67a0dbbee7
6 changed files with 33 additions and 32 deletions
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace KTXM\ProviderImap\Smtp\Protocol;
use KTXM\ProviderImap\Smtp\Protocol\Response\Response;
use KTXM\ProviderImap\Smtp\SmtpException;
use KTXM\ProviderImap\Smtp\Transport\ConnectionInterface;
use Psr\Log\LoggerInterface;
@@ -20,14 +21,14 @@ use Psr\Log\LoggerInterface;
* ("250-text") to indicate continuation and a space ("250 text") on the final
* line. See RFC 5321 §4.2.
*/
final class ReplyReader
final class ProtocolReader
{
public function __construct(
private readonly ConnectionInterface $connection,
private readonly ?LoggerInterface $logger = null,
) {}
public function read(): Reply
public function read(): Response
{
$lines = [];
$raw = '';
@@ -63,6 +64,6 @@ final class ReplyReader
'raw' => rtrim($raw, "\r\n"),
]);
return new Reply($code ?? 0, $lines, rtrim($raw, "\r\n"));
return new Response($code ?? 0, $lines, rtrim($raw, "\r\n"));
}
}
@@ -12,7 +12,7 @@ namespace KTXM\ProviderImap\Smtp\Protocol;
use KTXM\ProviderImap\Smtp\Transport\ConnectionInterface;
use Psr\Log\LoggerInterface;
final class CommandWriter
final class ProtocolWriter
{
public function __construct(
private readonly ConnectionInterface $connection,
@@ -7,12 +7,12 @@ declare(strict_types=1);
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderImap\Smtp\Protocol;
namespace KTXM\ProviderImap\Smtp\Protocol\Response;
/**
* A parsed SMTP reply: a 3-digit status code plus one or more text lines.
*/
final class Reply
final class Response
{
/**
* @param int $code 3-digit SMTP status code