I have managed to get text/html and text/plain parts of email, but now I need to get using strtok($part->contentType, ';') == "text/plain"
and strtok($part->contentType, ';') == "text/plain"
but now I need to get attachments (name, and to decode them). I have tried to do it via Content-Disposition
equal to attachment, but I cant get to Content-Disposition
from header array. So my question is how to get attachments from email using IMAP and ZF2? I saw couple similar questions like this and they are all submitted for previous version, I will need some newer solution.
Using Zend\Mail\Storage\Imap.
This is what I got when using print_r( $part->getHeaders() );
(this is only email part with attachment) :
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
)