views:

75

answers:

3

Is there a free open-source solution taking raw e-mail message (as a piece of text) and returning each header field, each attachment and the message body as separate fields?

+2  A: 

Yes... For each language you pointed out, I've used the one in Python myself. Try perusing the library documentation for your chosen library.

(Note: You may be expecting a "nice", high-level library for this parsing... That's a tricky area, email has evolved and grown without much design, there are a lot of dark corners, and API's reflect that).

Arafangion
+1  A: 

Yes, this is a common task and there are a number of apis out there to help you.

If working with Java, I'd look at JavaMail.

If working with PHP, I'd look at PECL mailparse or Pear Mail.

labratmatt
Hmm, judging by that tick, sounds like his real question was: "What is a good email parsing library for Java and PHP?"
Arafangion
A: 
javax.mail.internet.MimeMessage
    protected void parse(InputStream is)
irreputable