PHP SwiftMailer 从字符串到 Message 对象

PHP SwiftMailer from string to Message object

正如我们所知,我们可以从 Swift 消息对象中获取电子邮件字符串:

$message = new Swift_Message();
$message->setSubject("hi");
$message->attach(Swift_Attachment::fromPath('a.txt'));
$message->toString();

但是我可以将邮件字符串解析为 Message 对象吗? 太谢谢了!

Swift 邮件

不可能

我认为php-mime-mail-parser可以解决你的问题:

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