{"id":13622509,"url":"https://github.com/willdurand/EmailReplyParser","last_synced_at":"2025-04-15T09:32:38.018Z","repository":{"id":1861271,"uuid":"2786261","full_name":"willdurand/EmailReplyParser","owner":"willdurand","description":"PHP library for parsing plain text email content.","archived":false,"fork":false,"pushed_at":"2022-09-20T11:05:55.000Z","size":193,"stargazers_count":638,"open_issues_count":10,"forks_count":79,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-04-14T00:58:37.808Z","etag":null,"topics":["email","parser","php"],"latest_commit_sha":null,"homepage":"https://williamdurand.fr/EmailReplyParser/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"kcbanner/connect-mongo","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willdurand.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-11-16T07:27:29.000Z","updated_at":"2025-02-27T07:28:25.000Z","dependencies_parsed_at":"2022-07-08T00:18:48.750Z","dependency_job_id":null,"html_url":"https://github.com/willdurand/EmailReplyParser","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willdurand%2FEmailReplyParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willdurand%2FEmailReplyParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willdurand%2FEmailReplyParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willdurand%2FEmailReplyParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willdurand","download_url":"https://codeload.github.com/willdurand/EmailReplyParser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249043052,"owners_count":21203406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","parser","php"],"created_at":"2024-08-01T21:01:20.296Z","updated_at":"2025-04-15T09:32:37.963Z","avatar_url":"https://github.com/willdurand.png","language":"PHP","readme":"# EmailReplyParser\n\n[![GitHub Actions](https://github.com/willdurand/EmailReplyParser/workflows/ci/badge.svg)](https://github.com/willdurand/EmailReplyParser/actions?query=workflow%3A%22ci%22+branch%3Amaster)\n[![Total\nDownloads](https://poser.pugx.org/willdurand/email-reply-parser/downloads.png)](https://packagist.org/packages/willdurand/email-reply-parser)\n[![Latest Stable\nVersion](https://poser.pugx.org/willdurand/email-reply-parser/v/stable.png)](https://packagist.org/packages/willdurand/email-reply-parser)\n\n**EmailReplyParser** is a PHP library for parsing plain text email content,\nbased on GitHub's [email_reply_parser](http://github.com/github/email_reply_parser)\nlibrary written in Ruby.\n\n## Installation\n\nThe recommended way to install EmailReplyParser is through\n[Composer](http://getcomposer.org/):\n\n```shell\ncomposer require willdurand/email-reply-parser\n```\n\n## Usage\n\nInstantiate an `EmailParser` object and parse your email:\n\n```php\n\u003c?php\n\nuse EmailReplyParser\\Parser\\EmailParser;\n\n$email = (new EmailParser())-\u003eparse($emailContent);\n```\n\nYou get an `Email` object that contains a set of `Fragment` objects. The `Email`\nclass exposes two methods:\n\n- `getFragments()`: returns all fragments;\n- `getVisibleText()`: returns a string which represents the content considered\n  as \"visible\".\n\nThe `Fragment` represents a part of the full email content, and has the\nfollowing API:\n\n```php\n\u003c?php\n\n$fragment = current($email-\u003egetFragments());\n\n$fragment-\u003egetContent();\n\n$fragment-\u003eisSignature();\n\n$fragment-\u003eisQuoted();\n\n$fragment-\u003eisHidden();\n\n$fragment-\u003eisEmpty();\n```\n\nAlternatively, you can rely on the `EmailReplyParser` to either parse an email\nor get its visible content in a single line of code:\n\n```php\n$email = \\EmailReplyParser\\EmailReplyParser::read($emailContent);\n\n$visibleText = \\EmailReplyParser\\EmailReplyParser::parseReply($emailContent);\n```\n\n## Known Issues\n\n### Quoted Headers\n\nQuoted headers aren't picked up if there's an extra line break:\n\n    On \u003cdate\u003e, \u003cauthor\u003e wrote:\n\n    \u003e blah\n\nAlso, they're not picked up if the email client breaks it up into\nmultiple lines. GMail breaks up any lines over 80 characters for you.\n\n    On \u003cdate\u003e, \u003cauthor\u003e\n    wrote:\n    \u003e blah\n\nThe above `On ....wrote:` can be cleaned up with the following regex:\n\n```php\n$fragment_without_date_author = preg_replace(\n  '/\\nOn(.*?)wrote:(.*?)$/si',\n  \"\",\n  $fragment-\u003egetContent()\n);\n```\n\nNote though that we're search for \"on\" and \"wrote\". Therefore, it won't work\nwith other languages.\n\nPossible solution: Remove \"reply@reply.github.com\" lines...\n\n### Weird Signatures\n\nLines starting with `-` or `_` sometimes mark the beginning of\nsignatures:\n\n    Hello\n\n    --\n    Rick\n\nNot everyone follows this convention:\n\n    Hello\n\n    Mr Rick Olson\n    Galactic President Superstar Mc Awesomeville\n    GitHub\n\n    **********************DISCLAIMER***********************************\n    * Note: blah blah blah                                            *\n    **********************DISCLAIMER***********************************\n\n### Strange Quoting\n\nApparently, prefixing lines with `\u003e` isn't universal either:\n\n    Hello\n\n    --\n    Rick\n\n    ________________________________________\n    From: Bob [reply@reply.github.com]\n    Sent: Monday, March 14, 2011 6:16 PM\n    To: Rick\n\n## Unit Tests\n\nSetup the test suite using Composer:\n\n    $ composer install\n\nRun it using PHPUnit:\n\n    $ ./vendor/bin/simple-phpunit\n\n## Contributing\n\nSee CONTRIBUTING file.\n\n## Credits\n\n- GitHub\n- William Durand\n\n## License\n\nEmailReplyParser is released under the MIT License. See the bundled LICENSE\nfile for details.\n","funding_links":[],"categories":["Email","电子邮件 Email","Table of Contents","PHP","目录","邮件( Email )"],"sub_categories":["Email","电子邮件 Email"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilldurand%2FEmailReplyParser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilldurand%2FEmailReplyParser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilldurand%2FEmailReplyParser/lists"}