The PHP IMAP library uses the 'imap_headerinfo' function to grab the header objects. This function only returns a standard list of objects.
This patch tweaks the 'retrieve_message' function to include all of the header objects from an email.
With this tweak, the Mailhandler Extended Headers plugin can be used to grab any of these header objects. One example would be grabbing the 'List-Id' object from an email sent from a GNU Mailman email list.
This patch is based off the latest 7.x-2.x branch.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | missing_imap_headers-1703018-14.patch | 1.49 KB | jurgenhaas |
| #12 | missing_imap_headers-1703018-12.patch | 1.33 KB | jurgenhaas |
| #9 | 1703018-headers-9.patch | 1.77 KB | kscheirer |
| mailhandler-php_imap_tweak.patch | 1.39 KB | ronin17 |
Comments
Comment #2
danepowell commentedAwesome, thanks! I'll review this when I get a chance.
Comment #3
deltab commentedmailhandler-php_imap_tweak.patch queued for re-testing.
Comment #5
danepowell commentedFixed in 7.x-2.x-dev:
http://drupalcode.org/project/mailhandler.git/commit/ee2dad0
In the future, when submitting patches, please make sure that they conform to the Drupal code style guidelines. Thanks!
Comment #6
danepowell commentedI reverted the previous commit, as it causes tests to fail.
Comment #7
ronin17 commentedWhoops, sorry about that. For future reference, what part wasn't right?
I meant to post this a while ago, but I did have to modify the 'MailhandlerCommandsHeaders.class.php' file:
Line 24 was originally:
$message[$key] = iconv_mime_decode($value, 0, "UTF-8");I had to modify the decode options to continue on error, which looks like this:
$message[$key] = iconv_mime_decode($value, 2, "UTF-8");I was trying to get some things done and didn't have a chance to take a look at what I could have done to prevent the error in the first place without modifying the iconv_mime_decode options. Do you have any suggestions?
Thanks.
Comment #8
danepowell commentedUse spaces instead of tabs, put opening brackets on the same line as conditionals, various other items... see https://drupal.org/coding-standards
I haven't had time to investigate why iconv_mime_decode is failing, but I agree that simply telling it to ignore failures is probably not the correct approach. Looking in depth at the structure of the returned headers would probably shed some light on the situation.
Comment #9
kscheirerPatch rerolled against 7.x-2.x-dev and updated to Drupal code standards.
Not sure what's causing iconv to fail either, a malformed (?) header that we're now grabbing?
Comment #10
danepowell commentedhttp://drupalcode.org/project/mailhandler.git/commit/89b1582
http://drupalcode.org/project/mailhandler.git/commit/a8fe0e2
Thanks for the patch.
Comment #11
danepowell commentedWell that's annoying... the patch passed tests, but when I actually committed it, the tests failed.
Comment #12
jurgenhaasJust came across the requirement to use this patch and then realized that this approach comes with a whitespace problem. Simply adding a trim() as first thing in the foreach loop is resolving the issue. Re-rolled patch is attached.
Comment #14
jurgenhaasFix the patch
Comment #16
jurgenhaasNow the patch properly applies but the tests fail. Reviewing them I doubt that the failures are related to the patch here, the system doesn't seem to be able to create the mappings for the test and as a consequence the received email doesn't contain the expected content.