GithubHelp home page GithubHelp logo

Comments (9)

perk11 avatar perk11 commented on August 15, 2024

Values 7-10 are also returned by imap_fetchstructure for some messages for me.

from imap.

mrtimp avatar mrtimp commented on August 15, 2024

I've started seeing this issue within the past week from emails @didx.net, I'm not seeing them from anywhere else. Presuming the 'encoding' is derived from the Content-Transfer-Encoding header then their emails are seeing them to "quoted -printable" (without quotes). I haven't yet had sufficient time to replay this issue in my development environment and find a solution but when I do I will update this issue.

from imap.

mrtimp avatar mrtimp commented on August 15, 2024

Also, I'm using PHP 5.5.20-2 (CentOS 6) package from the REMI repository. PHP information shows:

IMAP c-Client Version => 2007e
SSL Support => enabled
Kerberos Support => enabled

from imap.

mrtimp avatar mrtimp commented on August 15, 2024

On closer inspection it looks like the remote mail client may be incorrectly building the header. I've noticed in all of the failed emails there is a space between quoted and -printable. May be able to apply a patch to Message/Part.php in the parseStructure method to look for broken encoding types and correct them. Depending on the reuse from the call to loadStructure in Message.php it may be better to apply the adjustments there.

from imap.

mrtimp avatar mrtimp commented on August 15, 2024

I've had some time tonight to investigate further. I must say that i'm conflicted on what the right thing to do here is. Part of me thinks in the real-world you need to work round quirks with broken email messages to ensure that it doesn't impact your ability to work with 'all email messages' and the other part of me thinks that you should reject them if they are invalid.

I'm more than happy to do a PR if the developers feel its something of value.

Either way, here is a diff of my changes to fix my scenario:

Index: src/Ddeboer/Imap/Message.php
===================================================================
--- src/Ddeboer/Imap/Message.php    (revision 2802)
+++ src/Ddeboer/Imap/Message.php    (working copy)
@@ -306,6 +306,23 @@
     protected function loadStructure()
     {
         $structure = \imap_fetchstructure($this->stream, $this->messageNumber, \FT_UID);
+
+       // look for an unknown character type encoding
+       // to provide manual overrides if applicable
+       if ($structure->encoding > 5) {
+           $headers = \imap_fetchheader($this->stream, $this->messageNumber, \FT_UID);
+
+           // match the character type encoding header to apply
+           // any additional manual fixups or overrides
+           if (preg_match('/^Content-Transfer-Encoding: (.*)$/im', $headers, $matches)) {
+               $matches[1] = trim(preg_replace('/\s+/', '', $matches[1]));
+
+               // pattern match other content type encoding that needs
+               // to be manually remapped to another encoding type
+               if ($matches[1] == 'quoted-printable') $structure->encoding = 4;
+           }
+       }
+
         $this->parseStructure($structure);
     }
 }
\ No newline at end of file

from imap.

mrtimp avatar mrtimp commented on August 15, 2024

@perk11 I would be interested to see messages that were returning values 7-10 from imap_fetchstructure if you have any examples.

from imap.

perk11 avatar perk11 commented on August 15, 2024

@mrtimp I'm not sure how to get full message text from debugger, here is structure of one of these messages: http://imgur.com/SAX4O97

from imap.

perk11 avatar perk11 commented on August 15, 2024

So I logged headers for ALL messages from the problem account in Message::loadStructure() and interestingly enough I failed to get encoding values greater than 6 in Message::loadStructure(), I only get them in Part::parseStructure(). I'm not sure how this is even possible, but this is what happens.

from imap.

Slamdunk avatar Slamdunk commented on August 15, 2024

Without examples and testable data, we can't do better than throw exception in case of unknown encoding, implemented in #197.

@mrtimp we can implement manual look up for Content-Transfer-Encoding, but only with examples and enviroments variables:

  1. What is the message full body?
  2. What is the IMAP server and configuration?

As soon as we'll have all this info, we'll adapt the code. Until that time, we'll stick with throwing an exception.

Thank you all for the feedbacks.

from imap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.