Looking for a library for email parsing

hello community

I want to parse the email raw format, and grab the plain text message body.
I did the job in python, such as this:

import email
import sys

f = open(file, "r")
x = f.read()

b = email.message_from_string(x)

if b.is_multipart():
    for part in b.get_payload():
        print part.get_payload()
    print b.get_payload()

Because our spark jobs were written by scala, i want to translate the code into scala. But I didn’t find a right library for this. can you suggest?

Thanks for all the kind helps.

I don’t know of a scala specific parser, however you have all of the java libraries available to you.

https://mvnrepository.com/artifact/org.apache.commons/commons-email/1.5 apache commons email has a MimeMessageParser which you should be able to use.

docs are here MimeMessageParser (Apache Commons Email 1.5 API)