in reply to Need help parsing email using MIME::Parser

The decoded message is written to disk by default, but I don't understand how to store the decoded body in an array so I can manipulate it.

Read the file? Yeah, read the file sounds good :)

  • Comment on Re: Need help parsing email using MIME::Parser

Replies are listed 'Best First'.
Re^2: Need help parsing email using MIME::Parser
by gossamer (Sexton) on Apr 01, 2015 at 00:37 UTC

    I figured it out. I knew it seemed stupid to not have some method of reading the unencoded file directly using the $entity that's already defined and accessing the full email.

    I just came across this:

    ### Read the (unencoded) body data: if ($io = $ent->open("r")) { while (defined($_ = $io->getline)) { print $_ } $io->close; }
Re^2: Need help parsing email using MIME::Parser
by gossamer (Sexton) on Mar 31, 2015 at 23:40 UTC
    Yes, thanks, of course I knew that, but isn't it possible to read from the file since it's already opened?

      Yes, thanks, of course I knew that, but isn't it possible to read from the file since it's already opened?

      Um, what file are you talking about?

      Use mimeexplode to unpack an email into a directory

      Then use any which way or Path::Tiny to read the files that got unpacked, they're like regular files at this point, not emails

        I meant that it already decodes it from the file being piped to STDIN, I just assumed there was also a function that allowed me to read that decoded stream as well.

        The output file that's created is already decoded, so I don't need any further MIME tools.

        I was also curious why the for() loop fails for $entry->parts for some reason. Isn't that a check for an encoded body or attachment?