Skip to content

Commit

Permalink
include message id provided by the MTA when dispatching the SentMessa…
Browse files Browse the repository at this point in the history
…geEvent
  • Loading branch information
xabbuh committed Feb 16, 2024
1 parent d352e98 commit 08b0b73
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -148,10 +147,6 @@ public function send(RawMessage $message, ?Envelope $envelope = null): ?SentMess
throw $e;
}

if ($this->mtaResult && $messageId = $this->parseMessageId($this->mtaResult)) {
$message->setMessageId($messageId);
}

$this->checkRestartThreshold();

return $message;
Expand Down Expand Up @@ -235,9 +230,13 @@ protected function doSend(SentMessage $message): void
$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;
Expand Down

0 comments on commit 08b0b73

Please sign in to comment.