Skip to content

Commit

Permalink
Fix for saving message id (#6)
Browse files Browse the repository at this point in the history
* Fix for saving message id

* Revert "Fix for saving message id"

This reverts commit 32570b4.

* Fix for saving message id

* Fix for saving message id (handle the case when message-id header is null)

* treat various cases for message-id type

* treated the default case for msg id class type

* Use instanceof in getMessageId method

---------

Co-authored-by: Tjardo <info@tjardo.com>
  • Loading branch information
andreifiroiu and tjardoo authored Jan 24, 2025
1 parent 4805d97 commit 6577ae7
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/Listeners/CreateMailViewerItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,30 @@ private function formatHeaders(Headers $headers): ?array

return [
'date' => $headers->get('date'),
'message-id' => $headers->get('message-id'),
'message-id' => $this->getMessageId($headers),
'from' => $headers->get('from'),
];
}

private function getMessageId(Headers $headers): mixed
{
$messageId = $headers->get('message-id');

if ($messageId instanceof \Symfony\Component\Mime\Header\UnstructuredHeader) {
return $messageId->getBodyAsString();
}

if ($messageId instanceof \Symfony\Component\Mime\Header\IdentificationHeader) {
return $messageId->getIds();
}

if (is_object($messageId)) {
return $messageId->toString();
}

return $messageId;
}

private function formatRecipients(Email $message): array
{
return array_merge(
Expand Down

0 comments on commit 6577ae7

Please sign in to comment.