3

有内容配置时如何提取邮件正文?

标题1

Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
x-originating-ip: [x.x.x.x]
Content-Type: application/pkcs7-mime; smime-type=signed-data;
    name="smime.p7m"
Content-Disposition: attachment; filename="smime.p7m"
Content-Transfer-Encoding: base64
MIME-Version: 1.0

标头2:

   Accept-Language: en-US
    Content-Language: en-US
    X-MS-Has-Attach:
    X-MS-TNEF-Correlator:
    x-originating-ip: [x.x.x.x]
    Content-Type: multipart/alternative;
        boundary="_000_A61C9CD725DF1C4FA94C13EC538A38BEEaz18ex3004_"
    MIME-Version: 1.0

当我签署邮件并发送时,邮件的标题格式为“header1”,当我发送邮件而不签名时,邮件的标题格式为“header2”..

我目前正在使用" getMessageBody()" methodmimemailparser.class.php文件中提取消息的正文..

在签名邮件上,我无法检索邮件正文,它在使用时返回空正文"getmessagebody()" method,但在未签名邮件上,它能够检索邮件正文..

在检查已签名和未签名的邮件标题时,有区别,如何在已签名邮件(header1)上提取邮件正文?

4

1 回答 1

0

查看getMessageBody()类中的方法,在代码的以下部分:

foreach($this->parts as $part) {
  if ($this->getPartContentType($part) == $mime_types[$type]) {
    $headers = $this->getPartHeaders($part);
    $body    = $this->decode($this->getPartBody($part), array_key_exists('content-transfer-encoding', $headers) ? $headers['content-transfer-encoding'] : '');
    break;
  }
}

类将 MIME 消息分成几部分,可能存在这样一种情况,即正文分为几部分,但代码仅解码第一部分(在您的情况下可能为空)。尝试像这样修改此代码:

foreach ($this->parts as $part) {
  if ($this->getPartContentType($part) == $mime_types[$type]) {
    $headers = $this->getPartHeaders($part);
    $body   .= $this->decode($this->getPartBody($part), array_key_exists('content-transfer-encoding', $headers) ? $headers['content-transfer-encoding'] : '');
  }
}
于 2013-10-01T19:32:40.850 回答