【问题标题】:Zend_Mail and =0D=0A=3D=3D=3D=3D=3DZend_Mail 和 =0D=0A=3D=3D=3D=3D=3D
【发布时间】:2010-12-20 12:49:15
【问题描述】:

我正在编写一个帮助台管道处理程序,将传入的电子邮件作为服务台票证回复进行管道传输。一些电子邮件非常顺利地进入,另一些则作为乱七八糟的文本进入,而 = 3D 则全部塞进一个巨大的字符串中。有没有人知道如何将其解码为纯文本。

作为参考,这是我的邮件解析器功能:

public function parseEmailMessage(Zend_Mail_Message $msg)
{
    if ($msg->isMultiPart()) {
        $arrAttachments = array();
        $body = '';
        // Multipart Mime Message
        foreach (new RecursiveIteratorIterator($msg) as $part) {
            try {

                $mimeType = strtok($part->contentType, ';');

                // Parse file name
                preg_match('/name="(?<filename>[a-zA-Z0-9.\-_]+)"/is', $part->contentType, $attachmentName);

                // Append plaintext results to $body
                // All other content parts will be treated as attachments
                switch ($mimeType) {
                    case 'text/plain':
                        $body .= trim($part->getContent()) . "\n";
                        break;
                    case 'text/html':
                        $body .= trim(strip_tags($part->getContent));
                        break;
                    default:
                        $arrAttachments[] = array(
                            'attachment_mime' => $mimeType,
                            'attachment_name' => $this->filterFileName($attachmentName['filename']),
                            'base64data' => trim($part->getContent())
                        );
                }

            } catch (Zend_Mail_Exception $e) {
                // ignore
            }
        }

        return array($body, $arrAttachments);
    } else {
        // Plain text message
        return array(trim($msg->getContent()), array());
    }
}

【问题讨论】:

  • 抱歉,不得不进来看看 =0D=0A=3D=3D=3D=3D 是关于什么的。

标签: php email zend-framework


【解决方案1】:

我猜想,不知何故,内容类型未正确指定,Zend 不知道如何对其进行解码。我知道我以前见过这个,但我不记得它是在哪里或如何“解决”的。

看起来quoted-printable 被视为纯文本。

【讨论】:

  • 这也发生在我们的一些脚本上 - 如果我没记错的话,Apple Mac 是罪魁祸首
  • 正是我想要的。 php中的函数称为quoted_printable_decode();你救了我几个小时的挫败感,谢谢
猜你喜欢
  • 2011-05-13
  • 1970-01-01
  • 2022-06-30
  • 2011-08-06
  • 1970-01-01
  • 1970-01-01
  • 2015-12-29
  • 2012-07-17
  • 2014-12-22
相关资源
最近更新 更多