代码之家  ›  专栏  ›  技术社区  ›  Mark

Zend_-mail and=0d=0a=3d=3d=3d=3d=3d

  •  5
  • Mark  · 技术社区  · 16 年前

    我正在编写一个帮助台管道处理程序,以将传入的电子邮件作为帮助台通知单答复。有些电子邮件收到的很好,有些则是乱七八糟的文本,=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());
        }
    }
    
    1 回复  |  直到 16 年前
        1
  •  5
  •   Tim Lytle    16 年前

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

    它看起来像引用的可打印文件被视为纯文本。