我想用PHP语言阅读Outlook .msg
邮件,但我不知道如何使用简单的文件读取功能来阅读。
我在我的 Linux 系统中启用了 Mailparse 扩展,通过使用它我可以正确读取 .eml
文件,但不能正确读取 .msg
。
你能指出我需要使用的正确代码或库吗?
提前致谢
最佳答案
https://github.com/hfig/MAPI会做的。
require 'autoload.php';
$newfn= "outlook.msg";
// message parsing and file IO are kept separate
$messageFactory = new Hfig\MAPI\MapiMessageFactory();
$documentFactory = new Hfig\MAPI\OLE\Pear\DocumentFactory();
$ole = $documentFactory->createFromFile($newfn);
$message = $messageFactory->parseMessage($ole);
// raw properties are available from the "properties" member
echo $message->properties['subject'], "\n";
// some properties have helper methods
echo $message->getSender(), "\n";
echo $message->getBody(), "\n";
// recipients and attachments are composed objects
foreach ($message->getRecipients() as $recipient) {
// eg "To: John Smith <john.smith@example.com>
echo sprintf('%s: %s', $recipient->getType(), (string)$recipient), "\n";
}
exit;
关于php - 如何在 php 中读取 .msg 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41736274/