update patch 1

This commit is contained in:
fiqhpratama
2024-12-02 01:18:34 +07:00
parent 453d9bb470
commit 25026b0a85
3380 changed files with 103529 additions and 363623 deletions
+25 -16
View File
@@ -14,6 +14,7 @@ namespace Symfony\Component\Mailer\Transport\Smtp;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Mailer\Envelope;
use Symfony\Component\Mailer\Exception\InvalidArgumentException;
use Symfony\Component\Mailer\Exception\LogicException;
use Symfony\Component\Mailer\Exception\TransportException;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
@@ -171,7 +172,7 @@ class SmtpTransport extends AbstractTransport
public function __toString(): string
{
if ($this->stream instanceof SocketStream) {
$name = sprintf('smtp%s://%s', ($tls = $this->stream->isTLS()) ? 's' : '', $this->stream->getHost());
$name = \sprintf('smtp%s://%s', ($tls = $this->stream->isTLS()) ? 's' : '', $this->stream->getHost());
$port = $this->stream->getPort();
if (!(25 === $port || ($tls && 465 === $port))) {
$name .= ':'.$port;
@@ -211,7 +212,7 @@ class SmtpTransport extends AbstractTransport
try {
$envelope = $message->getEnvelope();
$this->doMailFromCommand($envelope->getSender()->getEncodedAddress());
$this->doMailFromCommand($envelope->getSender()->getEncodedAddress(), $envelope->anyAddressHasUnicodeLocalpart());
foreach ($envelope->getRecipients() as $recipient) {
$this->doRcptToCommand($recipient->getEncodedAddress());
}
@@ -227,7 +228,7 @@ class SmtpTransport extends AbstractTransport
} catch (\Exception $e) {
$this->stream->terminate();
$this->started = false;
$this->getLogger()->debug(sprintf('Email transport "%s" stopped', __CLASS__));
$this->getLogger()->debug(\sprintf('Email transport "%s" stopped', __CLASS__));
throw $e;
}
$mtaResult = $this->executeCommand("\r\n.\r\n", [250]);
@@ -244,19 +245,27 @@ class SmtpTransport extends AbstractTransport
}
}
private function doHeloCommand(): void
protected function serverSupportsSmtpUtf8(): bool
{
$this->executeCommand(sprintf("HELO %s\r\n", $this->domain), [250]);
return false;
}
private function doMailFromCommand(string $address): void
private function doHeloCommand(): void
{
$this->executeCommand(sprintf("MAIL FROM:<%s>\r\n", $address), [250]);
$this->executeCommand(\sprintf("HELO %s\r\n", $this->domain), [250]);
}
private function doMailFromCommand(string $address, bool $smtputf8): void
{
if ($smtputf8 && !$this->serverSupportsSmtpUtf8()) {
throw new InvalidArgumentException('Invalid addresses: non-ASCII characters not supported in local-part of email.');
}
$this->executeCommand(\sprintf("MAIL FROM:<%s>%s\r\n", $address, $smtputf8 ? ' SMTPUTF8' : ''), [250]);
}
private function doRcptToCommand(string $address): void
{
$this->executeCommand(sprintf("RCPT TO:<%s>\r\n", $address), [250, 251, 252]);
$this->executeCommand(\sprintf("RCPT TO:<%s>\r\n", $address), [250, 251, 252]);
}
public function start(): void
@@ -265,7 +274,7 @@ class SmtpTransport extends AbstractTransport
return;
}
$this->getLogger()->debug(sprintf('Email transport "%s" starting', __CLASS__));
$this->getLogger()->debug(\sprintf('Email transport "%s" starting', __CLASS__));
$this->stream->initialize();
$this->assertResponseCode($this->getFullResponse(), [220]);
@@ -273,7 +282,7 @@ class SmtpTransport extends AbstractTransport
$this->started = true;
$this->lastMessageTime = 0;
$this->getLogger()->debug(sprintf('Email transport "%s" started', __CLASS__));
$this->getLogger()->debug(\sprintf('Email transport "%s" started', __CLASS__));
}
/**
@@ -289,7 +298,7 @@ class SmtpTransport extends AbstractTransport
return;
}
$this->getLogger()->debug(sprintf('Email transport "%s" stopping', __CLASS__));
$this->getLogger()->debug(\sprintf('Email transport "%s" stopping', __CLASS__));
try {
$this->executeCommand("QUIT\r\n", [221]);
@@ -297,7 +306,7 @@ class SmtpTransport extends AbstractTransport
} finally {
$this->stream->terminate();
$this->started = false;
$this->getLogger()->debug(sprintf('Email transport "%s" stopped', __CLASS__));
$this->getLogger()->debug(\sprintf('Email transport "%s" stopped', __CLASS__));
}
}
@@ -327,10 +336,10 @@ class SmtpTransport extends AbstractTransport
$valid = \in_array($code, $codes);
if (!$valid || !$response) {
$codeStr = $code ? sprintf('code "%s"', $code) : 'empty code';
$responseStr = $response ? sprintf(', with message "%s"', trim($response)) : '';
$codeStr = $code ? \sprintf('code "%s"', $code) : 'empty code';
$responseStr = $response ? \sprintf(', with message "%s"', trim($response)) : '';
throw new UnexpectedResponseException(sprintf('Expected response code "%s" but got ', implode('/', $codes)).$codeStr.$responseStr.'.', $code ?: 0);
throw new UnexpectedResponseException(\sprintf('Expected response code "%s" but got ', implode('/', $codes)).$codeStr.$responseStr.'.', $code ?: 0);
}
}
@@ -359,7 +368,7 @@ class SmtpTransport extends AbstractTransport
$this->stop();
if (0 < $sleep = $this->restartThresholdSleep) {
$this->getLogger()->debug(sprintf('Email transport "%s" sleeps for %d seconds after stopping', __CLASS__, $sleep));
$this->getLogger()->debug(\sprintf('Email transport "%s" sleeps for %d seconds after stopping', __CLASS__, $sleep));
sleep($sleep);
}