Class MimeParser

java.lang.Object
com.codename1.backend.mail.MimeParser

public final class MimeParser extends Object

Reads a received mail: an RFC 5322 message with MIME parts.

Headers are unfolded and their RFC 2047 encoded words decoded. Bodies in quoted-printable or base64 are decoded, nested multiparts (mixed, alternative, related) are walked, and the first text/plain and text/html parts that are not attachments become the text and HTML bodies. Every other leaf part is an attachment.

Only UTF-8 and ISO-8859-1 (and US-ASCII) are decoded as such; text in any other charset is read as UTF-8.

ReceivedMessage m = MimeParser.parse(bytes);
String subject = m.getSubject();
  • Method Details

    • parse

      public static ReceivedMessage parse(byte[] raw)
      Parses raw. A malformed message is read as far as it makes sense; this never throws for bad input.
      Parameters:
      raw - the message, CRLF or bare LF line ends
      Returns:
      the parsed message