updated streamline-setup v2

This commit is contained in:
2025-01-15 08:53:49 -08:00
committed by alec.turner
parent a2ce9248f0
commit 4b569f81b0
20228 changed files with 2932048 additions and 63204 deletions
@@ -15,7 +15,7 @@ use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mime\RawMessage;
/**
* Interface for mailers able to send emails synchronous and/or asynchronous.
* Interface for mailers able to send emails synchronously and/or asynchronously.
*
* Implementations must support synchronous and asynchronous sending.
*
@@ -64,6 +64,7 @@ class SendmailTransport extends AbstractTransport
$this->stream = new ProcessStream();
if (str_contains($this->command, ' -bs')) {
$this->stream->setCommand($this->command);
$this->stream->setInteractive(true);
$this->transport = new SmtpTransport($this->stream, $dispatcher, $logger);
}
}
@@ -39,7 +39,6 @@ class SmtpTransport extends AbstractTransport
private int $pingThreshold = 100;
private float $lastMessageTime = 0;
private AbstractStream $stream;
private string $mtaResult = '';
private string $domain = '[127.0.0.1]';
public function __construct(?AbstractStream $stream = null, ?EventDispatcherInterface $dispatcher = null, ?LoggerInterface $logger = null)
@@ -148,10 +147,6 @@ class SmtpTransport extends AbstractTransport
throw $e;
}
if ($this->mtaResult && $messageId = $this->parseMessageId($this->mtaResult)) {
$message->setMessageId($messageId);
}
$this->checkRestartThreshold();
return $message;
@@ -235,9 +230,13 @@ class SmtpTransport extends AbstractTransport
$this->getLogger()->debug(sprintf('Email transport "%s" stopped', __CLASS__));
throw $e;
}
$this->mtaResult = $this->executeCommand("\r\n.\r\n", [250]);
$mtaResult = $this->executeCommand("\r\n.\r\n", [250]);
$message->appendDebug($this->stream->getDebug());
$this->lastMessageTime = microtime(true);
if ($mtaResult && $messageId = $this->parseMessageId($mtaResult)) {
$message->setMessageId($messageId);
}
} catch (TransportExceptionInterface $e) {
$e->appendDebug($this->stream->getDebug());
$this->lastMessageTime = 0;
@@ -30,6 +30,7 @@ abstract class AbstractStream
protected $in;
/** @var resource|null */
protected $out;
protected $err;
private string $debug = '';
@@ -68,7 +69,7 @@ abstract class AbstractStream
public function terminate(): void
{
$this->stream = $this->out = $this->in = null;
$this->stream = $this->err = $this->out = $this->in = null;
}
public function readLine(): string
@@ -24,12 +24,18 @@ use Symfony\Component\Mailer\Exception\TransportException;
final class ProcessStream extends AbstractStream
{
private string $command;
private bool $interactive = false;
public function setCommand(string $command): void
{
$this->command = $command;
}
public function setInteractive(bool $interactive): void
{
$this->interactive = $interactive;
}
public function initialize(): void
{
$descriptorSpec = [
@@ -45,17 +51,27 @@ final class ProcessStream extends AbstractStream
}
$this->in = &$pipes[0];
$this->out = &$pipes[1];
$this->err = &$pipes[2];
}
public function terminate(): void
{
if (null !== $this->stream) {
fclose($this->in);
$out = stream_get_contents($this->out);
fclose($this->out);
proc_close($this->stream);
$err = stream_get_contents($this->err);
fclose($this->err);
if (0 !== $exitCode = proc_close($this->stream)) {
$errorMessage = 'Process failed with exit code '.$exitCode.': '.$out.$err;
}
}
parent::terminate();
if (!$this->interactive && isset($errorMessage)) {
throw new TransportException($errorMessage);
}
}
protected function getReadConnectionDescription(): string