我已经设法获取电子邮件的文本/html 和文本/纯文本部分,但现在我需要开始使用strtok($part->contentType, ';') == "text/plain"
,strtok($part->contentType, ';') == "text/plain"
但现在我需要获取附件(名称,并对其进行解码)。我试图通过Content-Disposition
等于附件来做到这一点,但我无法Content-Disposition
从标头数组中获取。所以我的问题是如何使用 IMAP 和 ZF2 从电子邮件中获取附件?我看到了几个类似的问题,它们都提交给以前的版本,我需要一些更新的解决方案。
使用 Zend\Mail\Storage\Imap。
这是我使用时得到的print_r( $part->getHeaders() );
(这只是带有附件的电子邮件部分):
Zend\Mail\Headers Object
(
[pluginClassLoader:protected] => Zend\Mail\Header\HeaderLoader Object
(
[plugins:protected] => Array
(
[bcc] => Zend\Mail\Header\Bcc
[cc] => Zend\Mail\Header\Cc
[contenttype] => Zend\Mail\Header\ContentType
[content_type] => Zend\Mail\Header\ContentType
[content-type] => Zend\Mail\Header\ContentType
[date] => Zend\Mail\Header\Date
[from] => Zend\Mail\Header\From
[message-id] => Zend\Mail\Header\MessageId
[mimeversion] => Zend\Mail\Header\MimeVersion
[mime_version] => Zend\Mail\Header\MimeVersion
[mime-version] => Zend\Mail\Header\MimeVersion
[received] => Zend\Mail\Header\Received
[replyto] => Zend\Mail\Header\ReplyTo
[reply_to] => Zend\Mail\Header\ReplyTo
[reply-to] => Zend\Mail\Header\ReplyTo
[sender] => Zend\Mail\Header\Sender
[subject] => Zend\Mail\Header\Subject
[to] => Zend\Mail\Header\To
)
)
[headersKeys:protected] => Array
(
[0] => contenttype
[1] => contentdisposition
[2] => contenttransferencoding
[3] => xattachmentid
)
[headers:protected] => Array
(
[0] => Zend\Mail\Header\ContentType Object
(
[type:protected] => application/octet-stream
[parameters:protected] => Array
(
[name] => listen.pls
)
)
[1] => Zend\Mail\Header\GenericHeader Object
(
[fieldName:protected] => Content-Disposition
[fieldValue:protected] => attachment; filename="listen.pls"
[encoding:protected] => ASCII
)
[2] => Zend\Mail\Header\GenericHeader Object
(
[fieldName:protected] => Content-Transfer-Encoding
[fieldValue:protected] => base64
[encoding:protected] => ASCII
)
[3] => Zend\Mail\Header\GenericHeader Object
(
[fieldName:protected] => X-Attachment-Id
[fieldValue:protected] => f_hlmfqj9o2
[encoding:protected] => ASCII
)
)
[encoding:protected] => ASCII
)