📧 Email reply parser library for Python with multi-language support
Project description
Mail Reply Parser 📧🐍
Multi-language email reply parsing for international environments 🌍
Mail clients handle reply formatting differently, making reliable parsing difficult. Thank god we have standards. This library splits text-based emails into separate replies based on common headers produced by different, multilingual clients usually indicating separation.
Replies can either present the whole mail message body, or strip headers, signatures and common disclaimers if required. Currently supported languages are:
- Dutch (
nl
) 🇳🇱 - English (
en
) 🇬🇧 - French (
fr
) 🇫🇷 - German (
de
) 🇩🇪 - Italian (
it
) 🇮🇹 - Japanese (
ja
) 🇯🇵 - Polish (
pl
) 🇵🇱
🏳️🌈 Adding more languages is quite easy!
This is an improved Python implementation of GitHub's Ruby-based email_reply_parser and an adaptation of Zapier's email-reply-parser which both split the mails in fragments instead of distinct replies. They also only support English.
⭐ Features
⭐ Easy to implement
⭐ Multilanguage Support
⭐ Text-based mail parsing
⭐ Detect headers, signatures and disclaimers
⭐ Fully type annotated
⭐ Easy-to-read code and well-tested
Overview 🔭
This library makes it easy to split an incoming mail into replies, making working with emails much more manageable and easily providing the text content for each reply – with or without signatures, disclaimers and headers.
For example, it can turn the following email:
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?
Into just the replied text content:
Awesome! I haven't had another problem with it.
Get started 👾
Installation
pip install mail-parser-reply
Parse Replies
from mailparser_reply import EmailReplyParser
mail_body = 'foobar'; languages = ['en', 'de']
mail_message = EmailReplyParser(languages=languages).read(text=mail_body)
print(mail_message.replies)
Or get only the latest reply using:
latest_reply = EmailReplyParser(languages=languages).parse_reply(text=mail_body)
Parser API
EmailMessage.text: Mail body
EmailMessage.languages: Languages to use for parsing headers
EmailMessage.replies: List of EmailReply; single parsed replies
EmailMessage.include_english: Always include English language for parsing
EmailMessage.default_language: Default language to use if language dictionary
doesn't include any other language codes
EmailMessage.HEADER_REGEX: RegEx for identifying headers, separating mails
EmailMessage.SIGNATURE_REGEX: RegEx for identifying signatures
EmailMessage.DISCLAIMERS_REGEX: RegEx for identifying disclaimers
EmailMessage.read(): Parse EmailMessage.text to EmailReply which
are then stored in EmailMessage.replies
EmailReply.content: Unprocessed mail body with headers, signatures, disclaimers
EmailReply.body: Mail body without headers, signatures, disclaimers
EmailReply.full_body: Mail body; just without headers
EmailReply.headers: Identified Headers
EmailReply.signatures: Identified Signatures
EmailReply.disclaimers: Identified disclaimers
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mail_parser_reply-1.32.tar.gz
.
File metadata
- Download URL: mail_parser_reply-1.32.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17422af5a2564b7ea057f96eb69a519ce9a9a36ac53a64d29038ad1e3a555fce |
|
MD5 | cd2211c701d584dee1a8749fe967be80 |
|
BLAKE2b-256 | 633445e2dcf227ee8e97e2ec8ec53abbdc96528e154d84f77cf7d327a8e11c38 |
File details
Details for the file mail_parser_reply-1.32-py3-none-any.whl
.
File metadata
- Download URL: mail_parser_reply-1.32-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77eb8ac6687b57cf1ab1196fde8f697eea6165eee86de39d468567bb0e47666d |
|
MD5 | 844eb6d8a75b89ae2879761a62a15c4a |
|
BLAKE2b-256 | 4cc43d85e251dbc5ea4c64afae89be462c416f46eacd118441f6f78d5b7b217c |