As we know we can get email string from Swift Message object:
$message = new Swift_Message();
$message->setSubject("hi");
$message->attach(Swift_Attachment::fromPath('a.txt'));
$message->toString();
But can I parse mail string into Message object ? Great thanks!
I think php-mime-mail-parser can solve your problem:
A fully tested email parser for PHP 7.1+ (mailparse extension wrapper). It's the most effective php email parser around in terms of performance, foreign character encoding, attachment handling, and ease of use. Internet Message Format RFC 822, 2822, 5322.
https://github.com/php-mime-mail-parser/php-mime-mail-parser