laminas / laminas-mime

Create and parse MIME messages and parts
https://docs.laminas.dev/laminas-mime/
BSD 3-Clause "New" or "Revised" License
29 stars 23 forks source link

Attachments can not be seperated from mail body correctly #5

Closed weierophinney closed 3 years ago

weierophinney commented 4 years ago

I try to get Attachments from a message but i allways get error:

2016-12-30T15:46:09+00:00 CRIT (2): Something went wrong: Line "Received: (qmail 5233 invoked from network); 30 Dec 2016 16:46:09 +0100 X-Fcrdns: Yes Received: from xxxxxxxxx.adsl.highway.telekom.at (HELO [xxx.xxx.xxx.xxx]) (xxx.xxx.xxx.xxx) (smtp-auth username lpi@dddddddd.dd, mechanism plain) by server.de (qpsmtpd/0.92) with (ECDHE-RSA-AES256-SHA encrypted) ESMTPSA; Fri, 30 Dec 2016 16:46:09 +0100 To: cj@sxxxxxx.com From: sssssd ddddn ddd@ddddd.com Subject: testmail Organization: ddddddddddddddddddd Message-ID: 5114d274-dde3-2ca5-6c9d-3bd59f59065a@ddddddddd Date: Fri, 30 Dec 2016 16:46:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------3FE86778A6885A966DF16AC3" X-User-Auth: Auth by lpi@ddddddd.com through xxx.xxx.xxx.xxx" does not match header format!

It's identical to https://github.com/zendframework/zendframework/issues/2606 which is closed.

$rawMsg = preg_replace('~\R~u', "\r\n", $rawMsg);

seems to be a quickfix, the mail can then be parsed, but the filenames cannot be read and are empty on the attachment object.

This is my sourcecode to split the message which comes from stdin.

        $rawMsg = preg_replace('~\R~u', "\r\n", $rawMsg);
        $message = new \Zend\Mail\Message();
        $headers = null;
        $content = null;

        \Zend\Mime\Decode::splitMessage($rawMsg, $headers, $content, \Zend\Mail\Headers::EOL);     
        $boundary = $headers->get('contenttype')->getParameter('boundary');
        $mimeMsg = \Zend\Mime\Message::createFromMessage($content, $boundary);
        $message->setHeaders($headers);
        $message->setBody($mimeMsg);
        $attachmentsDesc=$mimeMsg->getParts();
        $fileManager=new FileManager();

        foreach($attachmentsDesc as $attachment)
        {
            $this->log->debug($attachment->type);  // this property  holds content type, line break AND name 
            $this->log->debug($attachment->filename); // this is empty
       //     $fileData=$fileManager->storeStreamToInbox(base64_decode($attachment->getContent()), $attachment->filename);

            $this->log->debug("file created");
        }

Originally posted by @SevenbitsIt at https://github.com/zendframework/zend-mime/issues/23

weierophinney commented 3 years ago

This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steering Committee. If you have a security issue, please follow our security reporting guidelines. If you wish to take on the role of maintainer, please nominate yourself

If you are looking for an actively maintained package alternative, we recommend: