Skip to content

Commit 08b0b73

Browse files
committed
include message id provided by the MTA when dispatching the SentMessageEvent
1 parent d352e98 commit 08b0b73

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class SmtpTransport extends AbstractTransport
3939
private int $pingThreshold = 100;
4040
private float $lastMessageTime = 0;
4141
private AbstractStream $stream;
42-
private string $mtaResult = '';
4342
private string $domain = '[127.0.0.1]';
4443

4544
public function __construct(?AbstractStream $stream = null, ?EventDispatcherInterface $dispatcher = null, ?LoggerInterface $logger = null)
@@ -148,10 +147,6 @@ public function send(RawMessage $message, ?Envelope $envelope = null): ?SentMess
148147
throw $e;
149148
}
150149

151-
if ($this->mtaResult && $messageId = $this->parseMessageId($this->mtaResult)) {
152-
$message->setMessageId($messageId);
153-
}
154-
155150
$this->checkRestartThreshold();
156151

157152
return $message;
@@ -235,9 +230,13 @@ protected function doSend(SentMessage $message): void
235230
$this->getLogger()->debug(sprintf('Email transport "%s" stopped', __CLASS__));
236231
throw $e;
237232
}
238-
$this->mtaResult = $this->executeCommand("\r\n.\r\n", [250]);
233+
$mtaResult = $this->executeCommand("\r\n.\r\n", [250]);
239234
$message->appendDebug($this->stream->getDebug());
240235
$this->lastMessageTime = microtime(true);
236+
237+
if ($mtaResult && $messageId = $this->parseMessageId($mtaResult)) {
238+
$message->setMessageId($messageId);
239+
}
241240
} catch (TransportExceptionInterface $e) {
242241
$e->appendDebug($this->stream->getDebug());
243242
$this->lastMessageTime = 0;

0 commit comments

Comments
 (0)