{"id":19113310,"url":"https://github.com/opcodesio/mail-parser","last_synced_at":"2026-02-28T08:12:34.105Z","repository":{"id":190548540,"uuid":"682906096","full_name":"opcodesio/mail-parser","owner":"opcodesio","description":"Parse emails using PHP without the mailparse extension","archived":false,"fork":false,"pushed_at":"2025-03-04T04:57:11.000Z","size":25,"stargazers_count":17,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-09T22:11:37.350Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opcodesio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-25T06:29:28.000Z","updated_at":"2025-03-30T13:05:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"65e95933-66c2-4d9e-bada-d6ee9968bea2","html_url":"https://github.com/opcodesio/mail-parser","commit_stats":null,"previous_names":["opcodesio/mail-parser"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opcodesio%2Fmail-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opcodesio%2Fmail-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opcodesio%2Fmail-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opcodesio%2Fmail-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opcodesio","download_url":"https://codeload.github.com/opcodesio/mail-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119294,"owners_count":21050755,"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":[],"created_at":"2024-11-09T04:35:57.579Z","updated_at":"2026-02-28T08:12:34.097Z","avatar_url":"https://github.com/opcodesio.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003cp\u003e\n        \u003ch1\u003eMail Parser for PHP\u003cbr/\u003eSimple, fast, no extensions required\u003c/h1\u003e\n    \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e |\n    \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e |\n    \u003ca href=\"#credits\"\u003eCredits\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://packagist.org/packages/opcodesio/mail-parser\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/opcodesio/mail-parser.svg?style=flat-square\" alt=\"Packagist\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/opcodesio/mail-parser\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dm/opcodesio/mail-parser.svg?style=flat-square\" alt=\"Packagist\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/opcodesio/mail-parser\"\u003e\u003cimg src=\"https://img.shields.io/packagist/php-v/opcodesio/mail-parser.svg?style=flat-square\" alt=\"PHP from Packagist\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Features\n\n[OPcodes's](https://www.opcodes.io/) **Mail Parser** has a very simple API to parse emails and their MIME contents. Unlike many other parsers out there, this package does not require the [mailparse](https://www.php.net/manual/en/book.mailparse.php) PHP extension.\n\nHas not been fully tested against RFC 5322.\n\n## Get Started\n\n### Requirements\n\n- **PHP 8.0+**\n\n### Installation\n\nTo install the package via composer, Run:\n\n```bash\ncomposer require opcodesio/mail-parser\n```\n\n### Usage\n\n```php\nuse Opcodes\\MailParser\\Message;\n\n// Parse a message from a string\n$message = Message::fromString('...');\n// Or from a file location (accessible with file_get_contents())\n$message = Message::fromFile('/path/to/email.eml');\n\n$message-\u003egetHeaders();                 // get all headers\n$message-\u003egetHeader('Content-Type');    // 'multipart/mixed; boundary=\"----=_Part_1_1234567890\"'\n$message-\u003egetFrom();                    // 'Arunas \u003carunas@example.com\u003e\n$message-\u003egetTo();                      // 'John Doe \u003cjohndoe@example.com\u003e\n$message-\u003egetSubject();                 // 'Subject line'\n$message-\u003egetDate();                    // `Date:` header as DateTime object\n$message-\u003egetSize();                    // Email size in bytes\n\n$message-\u003egetParts();       // array of \\Opcodes\\MailParser\\MessagePart, which can be html parts, text parts, attachments, etc.\n$message-\u003egetHtmlPart();    // \\Opcodes\\MailParser\\MessagePart containing the HTML body\n$message-\u003egetTextPart();    // \\Opcodes\\MailParser\\MessagePart containing the Text body\n$message-\u003egetAttachments(); // array of \\Opcodes\\MailParser\\MessagePart that represent attachments\n\n$messagePart = $message-\u003egetParts()[0];\n\n$messagePart-\u003egetHeaders();                 // array of all headers for this message part\n$messagePart-\u003egetHeader('Content-Type');    // value of a particular header\n$messagePart-\u003egetContentType();             // 'text/html; charset=\"utf-8\"'\n$messagePart-\u003egetContent();                 // '\u003chtml\u003e\u003cbody\u003e....'\n$messagePart-\u003egetSize();                    // 312\n$messagePart-\u003egetFilename();                // name of the file, in case this is an attachment part\n```\n\n## Contributing\n\nA guide for contributing is in progress...\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Arunas Skirius](https://github.com/arukompas)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopcodesio%2Fmail-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopcodesio%2Fmail-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopcodesio%2Fmail-parser/lists"}