Skip to content

[Mailer] allow sub-classes to change the way the message id parsed #47108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function send(RawMessage $message, Envelope $envelope = null): ?SentMessa
throw $e;
}

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

Expand All @@ -156,15 +156,15 @@ public function send(RawMessage $message, Envelope $envelope = null): ?SentMessa
return $message;
}

protected function parseMessageId(): string
protected function parseMessageId(string $mtaResult): string
{
$regexps = [
'/250 Ok (?P<id>[0-9a-f-]+)\r?$/mis',
'/250 Ok:? queued as (?P<id>[A-Z0-9]+)\r?$/mis'
'/250 Ok:? queued as (?P<id>[A-Z0-9]+)\r?$/mis',
];
$matches = [];
foreach ($regexps as $regexp) {
if (preg_match($regexp, $this->mtaResult, $matches)) {
if (preg_match($regexp, $mtaResult, $matches)) {
return $matches['id'];
}
}
Expand Down