Email Reply Parser
Email Reply Parser is a Python library that simplifies the process of extracting the most recent reply from plain text email conversations. It is a port of GitHub's original Ruby email_reply_parser. The library helps in automatically stripping out quoted previous messages, signatures, and disclaimers, providing a cleaner, actionable response. The current version, 0.5.12, was released in October 2020, indicating a slow release cadence.
Warnings
- gotcha The parser primarily relies on English-specific heuristics (e.g., 'On <date>, <author> wrote:') for identifying quoted replies. It may not work correctly or be less effective with emails in other languages or with different reply header formats.
- gotcha This library is strictly designed for plain text emails. It does not process HTML email content, and feeding it HTML input may lead to incorrect or incomplete parsing results.
- gotcha Signature detection is heuristic-based (e.g., looking for lines starting with `--` or `__`). Its accuracy can vary significantly depending on the email client, custom signature formats, and general email content.
- gotcha Quoted headers (like 'On <date>, <author> wrote:') that span multiple lines due to email client formatting (e.g., Gmail's line-wrapping) may not be correctly identified and stripped, leading to quoted content appearing in the reply.
Install
-
pip install email-reply-parser
Imports
- EmailReplyParser
from email_reply_parser import EmailReplyParser
Quickstart
from email_reply_parser import EmailReplyParser
email_body = '''Hi there,
I appreciate your help with this issue.
Best regards,
John
On Mon, Apr 8, 2026 at 10:00 AM, Support <support@example.com> wrote:
> How can we help you today?
>
> Thanks,
> Support Team'''
# Get the full parsed email structure (list of fragments)
parsed_email = EmailReplyParser.read(email_body)
print("--- Full Parsed Email Fragments ---")
for fragment in parsed_email.fragments:
print(f"Content: {fragment.content.strip()}\nIs a signature: {fragment.is_signature}\nIs quoted: {fragment.is_quoted}\nIs hidden: {fragment.is_hidden}\n---")
# Get only the reply message (stripping quotes and signatures)
reply_text = EmailReplyParser.parse_reply(email_body)
print("\n--- Extracted Reply Text ---")
print(reply_text)