in reply to MIME voodoo.
You can do it using Email::MIME, it will parse the message and return you list of parts found, then you should just check content-type for every part and get what you want, no voodoo. Also http://emailproject.perl.org/ may be interesting for you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: MIME voodoo.
by vxp (Pilgrim) on Jul 16, 2009 at 18:56 UTC | |
Took a quick look, noticed something strange here's the input that I fed into it:
Here's the code I came up with:
That is pretty much from the module's documentation. Here's the result it produces, when I run it:
Shouldn't $parts[1] contain the second MIME in my input (html)? why's it undef'ed? and if I use @parts in scalar context, it claims there's only 1 mime part in that input, which is also a blatant lie. :) $parts[0] seems to contain what it's supposed to. it returns 'text/plain; charset="iso-8859-1"' as its supposed to. where'd $parts[1] go? :D Did I misinterpret the documentation somehow? | [reply] [d/l] [select] |
by zwon (Abbot) on Jul 16, 2009 at 19:05 UTC | |
Your input isn't correct MIME message. There should be header that defines boundary and it's missed. Here's some small and dirty (sorry...) example:
Upd: minor fix Upd: Note also that $_->content_type may return something like text/plain; charset=utf-8, and this code will fail in this case. | [reply] [d/l] [select] |
by vxp (Pilgrim) on Jul 16, 2009 at 19:37 UTC | |
This works, and doesn't work - at the same time. I think an explanation is due after a statement like that, so here goes: Take this code:
And also take this input:
When you run it, the results are as follows (this is the "WORKS" part):
Now, what does NOT work is that as I said in my original request - sometimes the plain text mime can be on top, sometimes its on the bottom. using this code, if you switch the two mimes around it doesn't work. try switchign them around, and tell the code to give you the html portion. it'll give you the plain text portion instead. Is there any way to specifically request a html or text portion (so it doesn't matter what order the MIMEs are in the input), to your knowledge? | [reply] [d/l] [select] |
by zwon (Abbot) on Jul 16, 2009 at 20:00 UTC | |
by vxp (Pilgrim) on Jul 16, 2009 at 20:10 UTC | |
| |