mail-parser-reply

1.36 · active · verified Thu Apr 16

mail-parser-reply is a Python library (current version 1.36) designed to parse and split incoming email messages into individual replies. It supports multiple languages and makes it easier to extract relevant text content, with options to strip headers, signatures, and disclaimers. The library is actively maintained, providing an improved, fully type-annotated implementation over older email reply parsing tools.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate `EmailReplyParser` with a list of languages and then use `read()` to get all parsed replies or `parse_reply()` to extract only the most recent reply from a given email body text.

from mailparser_reply import EmailReplyParser

mail_body = """Awesome! I haven't had another problem with it. Thanks, alfonsrv

On Wed, Dec 20, 2023 at 13:37, RAUSYS <info@rausys.de> wrote:
> The good news is that I've found a much better query for lastLocation.
> It should run much faster now. Can you double-check?
"""

# Instantiate the parser with desired languages
parser = EmailReplyParser(languages=['en', 'de'])

# Parse the entire email and get a list of EmailReply objects
email_message = parser.read(text=mail_body)
print("All replies:")
for reply in email_message.replies:
    print(f"- {reply.text}")

# Or get only the latest reply as a string
latest_reply = parser.parse_reply(text=mail_body)
print("\nLatest reply:")
print(latest_reply)

view raw JSON →