1

如何使用 Java 解析在 Linux 系统上生成的邮件文件?我的意思是,我希望能够提取文件中各种电子邮件的发件人、收件人、时间戳和主题。有什么建议么?

4

2 回答 2

2

javax.mail.internet.MimeMessage.parse(InputStream)

it's protected but you can subclass it to use the method. However, the file format is quite simple, if you just want some headers, why not parse it on your own?

于 2009-11-27T23:52:37.580 回答
1

Those files belong to the Mail Transfer Agent and maybe the user's mail client. Other programs should tread very softly or better yet keep out altogether. Or is your program a mail client?

The "clean" way to do this would be to open up an SMTP or IMAP connection to the mail server / MTA and ask it for pieces of mail on behalf of your user, using his credentials that he gives you.

There's a Java mail API for this that knows how to do this well: http://java.sun.com/products/javamail/ .

于 2009-11-27T23:47:23.747 回答