flufl.bounce is a Python library designed for robust detection and parsing of email bounce messages. It helps identify undeliverable emails, extract recipient information, and understand the reason for delivery failures. The current major version is 4.0, released in August 2023, and it receives updates as needed, typically for Python compatibility or bug fixes.
pip install flufl-bounceVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse a raw bounce email string into an `email.message.Message` object, then use `flufl.bounce.Bounce` to detect if it's a bounce and extract key information like bounce type, failed recipients, and diagnostic codes. Remember to always pass an `email.message.Message` object to the `Bounce` constructor.
Before passing to `Bounce`, convert your raw email string or bytes using `email.message_from_string()` or `email.message_from_bytes()` from the standard library's `email` module. Example: `msg = message_from_string(raw_email_content); bounce = Bounce(msg)`.
Remove parentheses when accessing `is_bounce`. Change `bounce.is_bounce()` to `bounce.is_bounce`.
Upgrade your Python environment to 3.8 or newer to use `flufl-bounce` 4.0+.
Migrate your code to use the `Bounce` class directly for bounce detection and parsing. The `Bounce` object itself now encapsulates the detection logic.