def msg_from_file(fp, fullParse=False, isBytes=False):
    """Read a file and parse its contents into a Message object model.
    Replacement for email.message_from_file().

    We use the HeaderParser subclass instead of Parser to avoid trying
    to parse the message body, instead setting the payload to the raw
    body as a string.  This is faster, and also helps us avoid
    problems trying to parse spam with broken MIME bodies."""
    from email.parser import Parser, HeaderParser, BytesParser, BytesHeaderParser
    parsers = (HeaderParser, Parser), (BytesHeaderParser, BytesParser)
    parser = parsers[int(isBytes)][int(fullParse)]
    return parser().parse(fp)
