从 eZ Components ezcMailMultipartReport 对象输出消息正文

发布于 2024-07-25 07:48:53 字数 18148 浏览 2 评论 0原文

我正在尝试使用 eZ Components 中的 ezcMailImapTransport 类输出从 imap 服务器检索到的消息的消息正文。

我能够连接并检索所有消息,但我不知道如何输出消息正文。

print_r($mail[0]->body); 的输出如下。 我只是不知道如何处理这样的物体。

该消息本身是电子邮件退回通知。

ezcMailMultipartReport Object
(
    [parts:protected] => Array
        (
            [0] => ezcMailText Object
                (
                    [headers:private] => ezcMailHeadersHolder Object
                        (
                            [lookup:private] => Array
                                (
                                    [content-description] => Content-Description
                                    [content-type] => Content-Type
                                )

                            [map:private] => Array
                                (
                                    [Content-Description] => Notification
                                    [Content-Type] => text/plain; charset=us-ascii
                                )

                        )

                    [headerCharsets:private] => Array
                        (
                            [Content-Description] => us-ascii
                            [Content-Type] => us-ascii
                        )

                    [excludeHeaders:private] => Array
                        (
                        )

                    [properties:protected] => Array
                        (
                            [text] => This is the mail system at host example.com.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system

: Host or domain name not found. Name service error for
    name=lskjsdf.com type=A: Host not found

                            [charset] => utf-8
                            [encoding] => 8bit
                            [subType] => plain
                            [originalCharset] => us-ascii
                            [size] => 501
                        )

                )

            [1] => ezcMailDeliveryStatus Object
                (
                    [headers:private] => ezcMailHeadersHolder Object
                        (
                            [lookup:private] => Array
                                (
                                )

                            [map:private] => Array
                                (
                                )

                        )

                    [headerCharsets:private] => Array
                        (
                        )

                    [excludeHeaders:private] => Array
                        (
                        )

                    [properties:protected] => Array
                        (
                            [message] => ezcMailHeadersHolder Object
                                (
                                    [lookup:private] => Array
                                        (
                                            [reporting-mta] => Reporting-MTA
                                            [x-postfix-queue-id] => X-Postfix-Queue-ID
                                            [x-postfix-sender] => X-Postfix-Sender
                                            [arrival-date] => Arrival-Date
                                        )

                                    [map:private] => Array
                                        (
                                            [Reporting-MTA] => dns; example.com
                                            [X-Postfix-Queue-ID] => 78A6E92D38
                                            [X-Postfix-Sender] => rfc822; [email protected]
                                            [Arrival-Date] => Fri, 12 Jun 2009 17:43:07 -0400 (EDT)
                                        )

                                )

                            [recipients] => ArrayObject Object
                                (
                                    [0] => ezcMailHeadersHolder Object
                                        (
                                            [lookup:private] => Array
                                                (
                                                    [final-recipient] => Final-Recipient
                                                    [original-recipient] => Original-Recipient
                                                    [action] => Action
                                                    [status] => Status
                                                    [diagnostic-code] => Diagnostic-Code
                                                )

                                            [map:private] => Array
                                                (
                                                    [Final-Recipient] => rfc822; [email protected]
                                                    [Original-Recipient] => rfc822;[email protected]
                                                    [Action] => failed
                                                    [Status] => 5.4.4
                                                    [Diagnostic-Code] => X-Postfix; Host or domain name not found. Name service error    for name=lskjsdf.com type=A: Host not found

                                                )

                                        )

                                )

                            [size] => 431
                        )

                )

            [2] => ezcMailRfc822Digest Object
                (
                    [headers:private] => ezcMailHeadersHolder Object
                        (
                            [lookup:private] => Array
                                (
                                    [content-type] => Content-Type
                                    [content-disposition] => Content-Disposition
                                )

                            [map:private] => Array
                                (
                                    [Content-Type] => message/rfc822
                                    [Content-Disposition] => inline
                                )

                        )

                    [headerCharsets:private] => Array
                        (
                            [Content-Type] => us-ascii
                            [Content-Disposition] => us-ascii
                        )

                    [excludeHeaders:private] => Array
                        (
                        )

                    [properties:protected] => Array
                        (
                            [mail] => ezcMail Object
                                (
                                    [headers:private] => ezcMailHeadersHolder Object
                                        (
                                            [lookup:private] => Array
                                                (
                                                    [received] => Received
                                                    [dkim-signature] => DKIM-Signature
                                                    [domainkey-signature] => DomainKey-Signature
                                                    [from] => From
                                                    [to] => To
                                                    [subject] => Subject
                                                    [mime-version] => MIME-Version
                                                    [user-agent] => User-Agent
                                                    [date] => Date
                                                    [message-id] => Message-Id
                                                    [content-type] => Content-Type
                                                    [content-transfer-encoding] => Content-Transfer-Encoding
                                                )

                                            [map:private] => Array
                                                (
                                                    [Received] => from localhost (example.com [127.0.0.1]) by example.com (Postfix) with ESMTP id 51C3192D2A for ; Fri, 12 Jun 2009 17:43:07 -0400 (EDT)
                                                    [DKIM-Signature] => v=1; a=rsa-sha1; c=relaxed; d=example.com; h=from:to :subject:mime-version:date:message-id:content-type :content-transfer-encoding; s=qs762.1; bh=o1jS7VG7S60y5SvP5lioDm 5B7VY=; b=Bojv0GjNWsHTRyiKZ631bvWczjntEJZsegrsU2tt/1EI4KVQnRXmT+ u4oX6cQTpPK2xxZfiZ3BymPsoOD3weKSFmdwDOEUB4vEDdG+Bx697345c+KaSpdw IlJh2o3x0Zus/Ov8xRelHX+/6sklnN1GDllEQV2JlcKdKxR+fUrOQ=
                                                    [DomainKey-Signature] => a=rsa-sha1; c=nofws; d=example.com; h=from:to :subject:mime-version:date:message-id:content-type :content-transfer-encoding; q=dns; s=qs762.1; b=HHzMU01/vNx4dBL5 OKyfxQzKytIIJB4KGhKWfFpSdsNNMPwCjrnRthz0wR4wqSgMIDmGobYOLujHekwM 1lLOAnMEQrXRWYHaIHBNIIrxemq1btuiMe8zNKEG3X/wSmYQE3xzInwPurB9iLAa Rjie7bJgTk0Tg+x54hav6l464Ok=
                                                    [From] => Example From
                                                    [To] => Ian Cook 
                                                    [Subject] => ezmail test 14:43:07
                                                    [MIME-Version] => 1.0
                                                    [User-Agent] => eZ Components
                                                    [Date] => Fri, 12 Jun 2009 14:43:07 -0700
                                                    [Message-Id] => <[email protected]>
                                                    [Content-Type] => text/plain; charset=us-ascii
                                                    [Content-Transfer-Encoding] => quoted-printable
                                                )

                                        )

                                    [headerCharsets:private] => Array
                                        (
                                            [Received] => us-ascii
                                            [DKIM-Signature] => us-ascii
                                            [DomainKey-Signature] => us-ascii
                                            [From] => us-ascii
                                            [To] => us-ascii
                                            [Subject] => us-ascii
                                            [MIME-Version] => us-ascii
                                            [User-Agent] => us-ascii
                                            [Date] => us-ascii
                                            [Message-Id] => us-ascii
                                            [Content-Type] => us-ascii
                                            [Content-Transfer-Encoding] => us-ascii
                                        )

                                    [excludeHeaders:private] => Array
                                        (
                                        )

                                    [properties:protected] => Array
                                        (
                                            [from] => ezcMailAddress Object
                                                (
                                                    [name] => Example From
                                                    [email] => [email protected]
                                                    [charset] => utf-8
                                                )

                                            [to] => Array
                                                (
                                                    [0] => ezcMailAddress Object
                                                        (
                                                            [name] => Ian Cook
                                                            [email] => [email protected]
                                                            [charset] => utf-8
                                                        )

                                                )

                                            [cc] => Array
                                                (
                                                )

                                            [bcc] => Array
                                                (
                                                )

                                            [subject] => ezmail test 14:43:07
                                            [subjectCharset] => utf-8
                                            [body] => ezcMailText Object
                                                (
                                                    [headers:private] => ezcMailHeadersHolder Object
                                                        (
                                                            [lookup:private] => Array
                                                                (
                                                                    [content-type] => Content-Type
                                                                    [content-transfer-encoding] => Content-Transfer-Encoding
                                                                )

                                                            [map:private] => Array
                                                                (
                                                                    [Content-Type] => text/plain; charset=us-ascii
                                                                    [Content-Transfer-Encoding] => quoted-printable
                                                                )

                                                        )

                                                    [headerCharsets:private] => Array
                                                        (
                                                            [Content-Type] => us-ascii
                                                            [Content-Transfer-Encoding] => us-ascii
                                                        )

                                                    [excludeHeaders:private] => Array
                                                        (
                                                        )

                                                    [properties:protected] => Array
                                                        (
                                                            [text] => Test mail sent at 14:43:07

                                                            [charset] => utf-8
                                                            [encoding] => 8bit
                                                            [subType] => plain
                                                            [originalCharset] => us-ascii
                                                            [size] => 27
                                                        )

                                                )

                                            [messageId] => <[email protected]>
                                            [returnPath] => 
                                        )

                                )

                            [size] => 1473
                        )

                )

        )

    [headers:private] => ezcMailHeadersHolder Object
        (
            [lookup:private] => Array
                (
                    [content-type] => Content-Type
                )

            [map:private] => Array
                (
                    [Content-Type] => multipart/report; boundary="78A6E92D38.1244842987/example.com"
                )

        )

    [headerCharsets:private] => Array
        (
            [Content-Type] => us-ascii
        )

    [excludeHeaders:private] => Array
        (
        )

    [properties:protected] => Array
        (
            [noMimeMessage] => This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
            [boundary] => 78A6E92D38.1244842987/example.com
            [reportType] => delivery-status
            [size] => 2405
        )

)

I'm attempting to output the message body of messages retrieved from my imap server, using the ezcMailImapTransport class from eZ Components.

I'm able to connect and retrieve all the messages, but I can't figure out how to output the message body.

The output of print_r($mail[0]->body); is below. I just don't know how to deal with an object like this.

The message itself is an email bounce notice.

ezcMailMultipartReport Object
(
    [parts:protected] => Array
        (
            [0] => ezcMailText Object
                (
                    [headers:private] => ezcMailHeadersHolder Object
                        (
                            [lookup:private] => Array
                                (
                                    [content-description] => Content-Description
                                    [content-type] => Content-Type
                                )

                            [map:private] => Array
                                (
                                    [Content-Description] => Notification
                                    [Content-Type] => text/plain; charset=us-ascii
                                )

                        )

                    [headerCharsets:private] => Array
                        (
                            [Content-Description] => us-ascii
                            [Content-Type] => us-ascii
                        )

                    [excludeHeaders:private] => Array
                        (
                        )

                    [properties:protected] => Array
                        (
                            [text] => This is the mail system at host example.com.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system

: Host or domain name not found. Name service error for
    name=lskjsdf.com type=A: Host not found

                            [charset] => utf-8
                            [encoding] => 8bit
                            [subType] => plain
                            [originalCharset] => us-ascii
                            [size] => 501
                        )

                )

            [1] => ezcMailDeliveryStatus Object
                (
                    [headers:private] => ezcMailHeadersHolder Object
                        (
                            [lookup:private] => Array
                                (
                                )

                            [map:private] => Array
                                (
                                )

                        )

                    [headerCharsets:private] => Array
                        (
                        )

                    [excludeHeaders:private] => Array
                        (
                        )

                    [properties:protected] => Array
                        (
                            [message] => ezcMailHeadersHolder Object
                                (
                                    [lookup:private] => Array
                                        (
                                            [reporting-mta] => Reporting-MTA
                                            [x-postfix-queue-id] => X-Postfix-Queue-ID
                                            [x-postfix-sender] => X-Postfix-Sender
                                            [arrival-date] => Arrival-Date
                                        )

                                    [map:private] => Array
                                        (
                                            [Reporting-MTA] => dns; example.com
                                            [X-Postfix-Queue-ID] => 78A6E92D38
                                            [X-Postfix-Sender] => rfc822; [email protected]
                                            [Arrival-Date] => Fri, 12 Jun 2009 17:43:07 -0400 (EDT)
                                        )

                                )

                            [recipients] => ArrayObject Object
                                (
                                    [0] => ezcMailHeadersHolder Object
                                        (
                                            [lookup:private] => Array
                                                (
                                                    [final-recipient] => Final-Recipient
                                                    [original-recipient] => Original-Recipient
                                                    [action] => Action
                                                    [status] => Status
                                                    [diagnostic-code] => Diagnostic-Code
                                                )

                                            [map:private] => Array
                                                (
                                                    [Final-Recipient] => rfc822; [email protected]
                                                    [Original-Recipient] => rfc822;[email protected]
                                                    [Action] => failed
                                                    [Status] => 5.4.4
                                                    [Diagnostic-Code] => X-Postfix; Host or domain name not found. Name service error    for name=lskjsdf.com type=A: Host not found

                                                )

                                        )

                                )

                            [size] => 431
                        )

                )

            [2] => ezcMailRfc822Digest Object
                (
                    [headers:private] => ezcMailHeadersHolder Object
                        (
                            [lookup:private] => Array
                                (
                                    [content-type] => Content-Type
                                    [content-disposition] => Content-Disposition
                                )

                            [map:private] => Array
                                (
                                    [Content-Type] => message/rfc822
                                    [Content-Disposition] => inline
                                )

                        )

                    [headerCharsets:private] => Array
                        (
                            [Content-Type] => us-ascii
                            [Content-Disposition] => us-ascii
                        )

                    [excludeHeaders:private] => Array
                        (
                        )

                    [properties:protected] => Array
                        (
                            [mail] => ezcMail Object
                                (
                                    [headers:private] => ezcMailHeadersHolder Object
                                        (
                                            [lookup:private] => Array
                                                (
                                                    [received] => Received
                                                    [dkim-signature] => DKIM-Signature
                                                    [domainkey-signature] => DomainKey-Signature
                                                    [from] => From
                                                    [to] => To
                                                    [subject] => Subject
                                                    [mime-version] => MIME-Version
                                                    [user-agent] => User-Agent
                                                    [date] => Date
                                                    [message-id] => Message-Id
                                                    [content-type] => Content-Type
                                                    [content-transfer-encoding] => Content-Transfer-Encoding
                                                )

                                            [map:private] => Array
                                                (
                                                    [Received] => from localhost (example.com [127.0.0.1]) by example.com (Postfix) with ESMTP id 51C3192D2A for ; Fri, 12 Jun 2009 17:43:07 -0400 (EDT)
                                                    [DKIM-Signature] => v=1; a=rsa-sha1; c=relaxed; d=example.com; h=from:to :subject:mime-version:date:message-id:content-type :content-transfer-encoding; s=qs762.1; bh=o1jS7VG7S60y5SvP5lioDm 5B7VY=; b=Bojv0GjNWsHTRyiKZ631bvWczjntEJZsegrsU2tt/1EI4KVQnRXmT+ u4oX6cQTpPK2xxZfiZ3BymPsoOD3weKSFmdwDOEUB4vEDdG+Bx697345c+KaSpdw IlJh2o3x0Zus/Ov8xRelHX+/6sklnN1GDllEQV2JlcKdKxR+fUrOQ=
                                                    [DomainKey-Signature] => a=rsa-sha1; c=nofws; d=example.com; h=from:to :subject:mime-version:date:message-id:content-type :content-transfer-encoding; q=dns; s=qs762.1; b=HHzMU01/vNx4dBL5 OKyfxQzKytIIJB4KGhKWfFpSdsNNMPwCjrnRthz0wR4wqSgMIDmGobYOLujHekwM 1lLOAnMEQrXRWYHaIHBNIIrxemq1btuiMe8zNKEG3X/wSmYQE3xzInwPurB9iLAa Rjie7bJgTk0Tg+x54hav6l464Ok=
                                                    [From] => Example From
                                                    [To] => Ian Cook 
                                                    [Subject] => ezmail test 14:43:07
                                                    [MIME-Version] => 1.0
                                                    [User-Agent] => eZ Components
                                                    [Date] => Fri, 12 Jun 2009 14:43:07 -0700
                                                    [Message-Id] => <[email protected]>
                                                    [Content-Type] => text/plain; charset=us-ascii
                                                    [Content-Transfer-Encoding] => quoted-printable
                                                )

                                        )

                                    [headerCharsets:private] => Array
                                        (
                                            [Received] => us-ascii
                                            [DKIM-Signature] => us-ascii
                                            [DomainKey-Signature] => us-ascii
                                            [From] => us-ascii
                                            [To] => us-ascii
                                            [Subject] => us-ascii
                                            [MIME-Version] => us-ascii
                                            [User-Agent] => us-ascii
                                            [Date] => us-ascii
                                            [Message-Id] => us-ascii
                                            [Content-Type] => us-ascii
                                            [Content-Transfer-Encoding] => us-ascii
                                        )

                                    [excludeHeaders:private] => Array
                                        (
                                        )

                                    [properties:protected] => Array
                                        (
                                            [from] => ezcMailAddress Object
                                                (
                                                    [name] => Example From
                                                    [email] => [email protected]
                                                    [charset] => utf-8
                                                )

                                            [to] => Array
                                                (
                                                    [0] => ezcMailAddress Object
                                                        (
                                                            [name] => Ian Cook
                                                            [email] => [email protected]
                                                            [charset] => utf-8
                                                        )

                                                )

                                            [cc] => Array
                                                (
                                                )

                                            [bcc] => Array
                                                (
                                                )

                                            [subject] => ezmail test 14:43:07
                                            [subjectCharset] => utf-8
                                            [body] => ezcMailText Object
                                                (
                                                    [headers:private] => ezcMailHeadersHolder Object
                                                        (
                                                            [lookup:private] => Array
                                                                (
                                                                    [content-type] => Content-Type
                                                                    [content-transfer-encoding] => Content-Transfer-Encoding
                                                                )

                                                            [map:private] => Array
                                                                (
                                                                    [Content-Type] => text/plain; charset=us-ascii
                                                                    [Content-Transfer-Encoding] => quoted-printable
                                                                )

                                                        )

                                                    [headerCharsets:private] => Array
                                                        (
                                                            [Content-Type] => us-ascii
                                                            [Content-Transfer-Encoding] => us-ascii
                                                        )

                                                    [excludeHeaders:private] => Array
                                                        (
                                                        )

                                                    [properties:protected] => Array
                                                        (
                                                            [text] => Test mail sent at 14:43:07

                                                            [charset] => utf-8
                                                            [encoding] => 8bit
                                                            [subType] => plain
                                                            [originalCharset] => us-ascii
                                                            [size] => 27
                                                        )

                                                )

                                            [messageId] => <[email protected]>
                                            [returnPath] => 
                                        )

                                )

                            [size] => 1473
                        )

                )

        )

    [headers:private] => ezcMailHeadersHolder Object
        (
            [lookup:private] => Array
                (
                    [content-type] => Content-Type
                )

            [map:private] => Array
                (
                    [Content-Type] => multipart/report; boundary="78A6E92D38.1244842987/example.com"
                )

        )

    [headerCharsets:private] => Array
        (
            [Content-Type] => us-ascii
        )

    [excludeHeaders:private] => Array
        (
        )

    [properties:protected] => Array
        (
            [noMimeMessage] => This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
            [boundary] => 78A6E92D38.1244842987/example.com
            [reportType] => delivery-status
            [size] => 2405
        )

)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

知你几分 2024-08-01 07:48:53

我不使用 EzComponents,但是您查看过 http:// /ezcomponents.org/docs/api/trunk/Mail/ezcMailMultipartReport.html#getParts 执行以下操作:

$parts = $mail->getParts();
print_r($parts);  // or
print_r($parts[0]->body);  // (untested)

ezcMailMultipartReport 只是 ezcMailMultipart 的子类,因此可以执行的所有操作(或其自己的父类) 、ezcMailPart)可用。

I don't use the EzComponents, but have you looked at http://ezcomponents.org/docs/api/trunk/Mail/ezcMailMultipartReport.html#getParts to do something like:

$parts = $mail->getParts();
print_r($parts);  // or
print_r($parts[0]->body);  // (untested)

ezcMailMultipartReport is just a sub-class of ezcMailMultipart, and so all the actions that can take (or it's own parent, ezcMailPart), are available.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文