Hi Monks. I'm using MIME::Parser to parse some emails. I'm trying to get the attached images and all works well until I came across .mac webmail. A mail comes which looks like this
--Apple-Mail-30--196590585 Content-Disposition: inline; filename=moriyama1.gif Content-Transfer-Encoding: base64 Content-Type: application/applefile; name="moriyama1.gif" AAUWBwACAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAJAAAAMgAAAAoAAAADAAAAPAAAAA1HSU +ZmcHJ2 dwEAbW9yaXlhbWExLmdpZg== --Apple-Mail-30--196590585 Content-Disposition: inline; filename=moriyama1.gif Content-Transfer-Encoding: base64 Content-Type: image/gif; x-mac-creator=70727677; x-unix-mode=0644; x-mac-type=47494666; name="moriyama1.gif" R0lGODlhZABnALMAAPDv79LR0FJQT66trJGQjykoJ9zb2m9ubebl5aCfnbu5uMfFxIKBfw +EBAQIC AgAAACH5BAA [etc...] --Apple-Mail-30--196590585--

Here the parser chokes on the image. Since I have never seen any of the other images with two headers like this, can I assume it is because the mail software is formatting it strangly? If so how can I get the real image which starts with the Content-Type: image/gif ?

My code looks like this. (I know this is not pretty, and I'm open to sugegstions to make it nice, but the thing I really care abotu is just getting the image now)

foreach my $part (@parts) { next unless defined $part->head; my $head_string = $part->head->as_string; next unless $head_string =~ m!text/plain|alternative|image|oct +et|gif!i; my $body_string = $part->bodyhandle->as_string; my @part = ($head_string, $body_string); push(@text, \@part) if $head_string =~ m!text/plain|altern +ative!i; push(@images, \@part) if $head_string =~ m!image|octet|gif +!i; } $thing->{'images'} = \@images; $thing->{'text'} = \@text; return($thing); }

If I don't have the next statement in there, it dies when the parser failes on thje "application/applefile" header. If I put in the next statement, it skips that header, but also skips the images.

Is there anything I can do about this without having to ditch MIME::Parser (I really really really want it to work with MIME::Parser)

K

In reply to MIME::Parser and applefile by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.