andrifix / email-reply-trimmer
PHP port of Ruby email_reply_trimmer
v1.2.1
2025-05-01 16:20 UTC
Requires
- php: >=8.3
Requires (Dev)
- phpunit/phpunit: ^12.1
README
This is a port of the discourse/email_reply_trimmer library. It's a small library to trim replies from plain text email.
Install
Install via Composer:
composer require andrifix/email-reply-trimmer
Usage
To trim replies:
$trimmed_body = EmailReplyTrimmer::trim($email_body);
You can also split the trimmed content and the elided part (the removed reply):
[$trimmedBody, $elidedContent] = EmailReplyTrimmer::trim($emailBody, true);
To extract the first embedded email section:
$extracted = EmailReplyTrimmer::extractEmbeddedEmail($emailBodyWithEmbedded); if ($extracted) { [$embeddedEmail, $beforeEmbedded] = $extracted; echo "Text Before Embedded Email: $beforeEmbedded\n"; echo "Embedded Email $embeddedEmail:\n"; } else { echo "No embedded email found."; }