{"id":13519705,"url":"https://github.com/barbushin/php-imap","last_synced_at":"2026-10-19T11:50:34.778Z","repository":{"id":448251,"uuid":"7029041","full_name":"barbushin/php-imap","owner":"barbushin","description":"Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)","archived":false,"fork":false,"pushed_at":"2026-05-10T18:58:46.000Z","size":1271,"stargazers_count":1699,"open_issues_count":51,"forks_count":452,"subscribers_count":66,"default_branch":"master","last_synced_at":"2026-10-12T17:56:28.412Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/barbushin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2012-12-06T03:16:38.000Z","updated_at":"2026-09-17T04:23:40.000Z","dependencies_parsed_at":"2026-05-10T13:03:06.282Z","dependency_job_id":null,"html_url":"https://github.com/barbushin/php-imap","commit_stats":{"total_commits":842,"total_committers":85,"mean_commits":9.905882352941177,"dds":0.5403800475059383,"last_synced_commit":"94107fdd1383285459a7f6c2dd2f39e25a1b8373"},"previous_names":[],"tags_count":66,"template":false,"template_full_name":null,"purl":"pkg:github/barbushin/php-imap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbushin%2Fphp-imap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbushin%2Fphp-imap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbushin%2Fphp-imap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbushin%2Fphp-imap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barbushin","download_url":"https://codeload.github.com/barbushin/php-imap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbushin%2Fphp-imap/sbom","scorecard":{"id":225704,"data":{"date":"2025-08-11","repo":{"name":"github.com/barbushin/php-imap","commit":"94107fdd1383285459a7f6c2dd2f39e25a1b8373"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":2,"reason":"Found 3/13 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/php_code_coverage.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/barbushin/php-imap/php_code_coverage.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/php_code_coverage.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/barbushin/php-imap/php_code_coverage.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/php_code_coverage.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/barbushin/php-imap/php_code_coverage.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/php_code_coverage.yml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/barbushin/php-imap/php_code_coverage.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/php_static_analysis.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/barbushin/php-imap/php_static_analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/php_static_analysis.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/barbushin/php-imap/php_static_analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/php_static_analysis.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/barbushin/php-imap/php_static_analysis.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/php_unit_tests.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/barbushin/php-imap/php_unit_tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/php_unit_tests.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/barbushin/php-imap/php_unit_tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/php_unit_tests.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/barbushin/php-imap/php_unit_tests.yml/master?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/php_code_coverage.yml:1","Warn: no topLevel permission defined: .github/workflows/php_static_analysis.yml:1","Warn: no topLevel permission defined: .github/workflows/php_unit_tests.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T03:46:05.102Z","repository_id":448251,"created_at":"2025-08-17T03:46:05.102Z","updated_at":"2025-08-17T03:46:05.102Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":344872684,"owners_count":38356429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-10-03T21:59:58.778Z","status":"online","status_checked_at":"2026-10-19T02:00:06.414Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-01T05:02:02.158Z","updated_at":"2026-10-19T11:50:34.771Z","avatar_url":"https://github.com/barbushin.png","language":"PHP","funding_links":[],"categories":["Table of Contents","PHP","目录","Networking and Distributed"],"sub_categories":["Email","电子邮件 Email","Networking","Library"],"readme":"# PHP IMAP\n\n[![GitHub release](https://img.shields.io/github/release/barbushin/php-imap.svg?style=flat-square)](https://packagist.org/packages/php-imap/php-imap)\n[![Supported PHP Version](https://img.shields.io/packagist/php-v/php-imap/php-imap.svg)](README.md)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Packagist](https://img.shields.io/packagist/dt/php-imap/php-imap.svg?style=flat-square)](https://packagist.org/packages/php-imap/php-imap)\n\n[![CI PHP Unit Tests](https://github.com/barbushin/php-imap/actions/workflows/php_unit_tests.yml/badge.svg?branch=master)](https://github.com/barbushin/php-imap/actions/workflows/php_unit_tests.yml)\n[![CI PHP Static Analysis](https://github.com/barbushin/php-imap/actions/workflows/php_static_analysis.yml/badge.svg?branch=master)](https://github.com/barbushin/php-imap/actions/workflows/php_static_analysis.yml)\n[![CI PHP Code Coverage](https://github.com/barbushin/php-imap/actions/workflows/php_code_coverage.yml/badge.svg?branch=master)](https://github.com/barbushin/php-imap/actions/workflows/php_code_coverage.yml)\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/02f72a4fd695cb7e2976/maintainability)](https://codeclimate.com/github/barbushin/php-imap/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/02f72a4fd695cb7e2976/test_coverage)](https://codeclimate.com/github/barbushin/php-imap/test_coverage)\n[![Type Coverage](https://shepherd.dev/github/barbushin/php-imap/coverage.svg)](https://shepherd.dev/github/barbushin/php-imap)\n\nInitially released in December 2012, the PHP IMAP Mailbox is a powerful and open source library to connect to a mailbox by POP3, IMAP and NNTP using the PHP IMAP extension (`ext-imap`). This library allows you to fetch emails from your email server. Extend the functionality or create powerful web applications to handle your incoming emails.\n\n### Features\n\n* Connect to mailbox by POP3/IMAP/NNTP, using [PHP IMAP extension](https://www.php.net/manual/book.imap.php)\n* Get emails with attachments and inline images\n* Get emails filtered or sorted by custom criteria\n* Mark emails as seen/unseen\n* Delete emails\n* Manage mailbox folders\n\n### Requirements\n\n| PHP Version  | php-imap Version | php-imap status |\n| ------------- | ------------- | ------------- |\n| 5.6  | 3.x  | End of life |\n| 7.0  | 3.x  | End of life |\n| 7.1  | 3.x  | End of life |\n| 7.2  | 3.x, 4.x | End of life |\n| 7.3  | 3.x, 4.x | End of life |\n| 7.4  | \u003e3.0.33, 4.x, 5.x | End of life |\n| 8.0  | \u003e3.0.33, 4.x, 5.x | End of life |\n| 8.1  | \u003e4.3.0, 5.x | End of life |\n| 8.2  | 6.x | Active support |\n| 8.3  | 6.x | Active support |\n| 8.4  | 6.x | Active support |\n| 8.5  | 6.x | Active support |\n\nThe next major release raises the minimum supported PHP version to PHP 8.2 and is tested on PHP 8.2 through PHP 8.5.\n\n* PHP `fileinfo`, `iconv`, `mbstring`, and `json` extensions must be present.\n* PHP `ext-imap` must be present.\n* On PHP `8.2` and `8.3`, install or enable the IMAP extension provided by your PHP distribution. On Windows, this can still mean enabling `extension=php_imap.dll` in `php.ini`.\n* On PHP `8.4` and newer, install IMAP from PECL and enable it for your CLI and web SAPIs.\n* When building IMAP from source, you may also need `c-client`, OpenSSL, and Kerberos development libraries.\n* `ext-imap` is not thread-safe and should not be used with ZTS builds.\n\n### Installation by Composer\n\nBefore running `composer require` or `composer install`, make sure `ext-imap` is installed for the PHP version you are using.\n\nInstall the [latest available release](https://github.com/barbushin/php-imap/releases):\n\n\t$ composer require php-imap/php-imap\n\nInstall the latest available and stable source code from `master`, which is may not released / tagged yet:\n\n\t$ composer require php-imap/php-imap:dev-master\n\n### Run Tests\n\nBefore you can run any tests you need a working `ext-imap` installation and you may need to run `composer install` to install all development dependencies.\n\n#### Run all tests\n\nYou can run all available tests by running the following command (inside of the installed `php-imap` directory): `composer run tests`\n\n#### Run only PHPUnit tests\n\nYou can run all PHPUnit tests by running the following command (inside of the installed `php-imap` directory): `php vendor/bin/phpunit --testdox`\n\n### Integration with frameworks\n\n* Symfony - https://github.com/secit-pl/imap-bundle\n\n### Getting Started Example\n\nBelow, you'll find an example code how you can use this library. For further information and other examples, you may take a look at the [wiki](https://github.com/barbushin/php-imap/wiki).\n\nBy default, this library uses random filenames for attachments as identical file names from other emails would overwrite other attachments. If you want to keep the original file name, you can set the attachment filename mode to `true`. For backward compatibility, this still overwrites an existing file with the same name. If you want to keep the original file name and automatically suffix duplicates with ` (1)`, ` (2)`, and so on, set the attachment filename collision mode to `PhpImap\\Mailbox::ATTACHMENT_FILENAME_COLLISION_SUFFIX`.\n\n```php\n// Create PhpImap\\Mailbox instance for all further actions\n$mailbox = new PhpImap\\Mailbox(\n\t'{imap.gmail.com:993/imap/ssl}INBOX', // IMAP server and mailbox folder\n\t'some@gmail.com', // Username for the before configured mailbox\n\t'*********', // Password for the before configured username\n\t__DIR__, // Directory, where attachments will be saved (optional)\n\t'UTF-8', // Server encoding (optional)\n    true, // Trim leading/ending whitespaces of IMAP path (optional)\n    false // Attachment filename mode (optional; false = random filename; true = original filename)\n);\n\n$mailbox-\u003esetAttachmentFilenameCollisionMode(\n    PhpImap\\Mailbox::ATTACHMENT_FILENAME_COLLISION_SUFFIX\n);\n\n// set some connection arguments (if appropriate)\n$mailbox-\u003esetConnectionArgs(\n    CL_EXPUNGE // expunge deleted mails upon mailbox close\n    | OP_SECURE // don't do non-secure authentication\n);\n\n// Some providers require OAuth instead of a password.\n// Obtain and refresh the access token outside of this library, then enable OAuth explicitly.\n// Your ext-imap build must expose OP_XOAUTH2 for this to work.\n$mailbox-\u003eenableOAuth($accessToken);\n\ntry {\n\t// Get all emails (messages)\n\t// PHP.net imap_search criteria: http://php.net/manual/en/function.imap-search.php\n\t$mailsIds = $mailbox-\u003esearchMailbox('ALL');\n} catch(PhpImap\\Exceptions\\ConnectionException $ex) {\n\techo \"IMAP connection failed: \" . implode(\",\", $ex-\u003egetErrors('all'));\n\tdie();\n}\n\n// If $mailsIds is empty, no emails could be found\nif(!$mailsIds) {\n\tdie('Mailbox is empty');\n}\n\n// If you want to inspect a message without changing its seen state,\n// use getMail($id, false) or getRawMail($id, false).\n\n// Get the first message\n// If '__DIR__' was defined in the first line, it will automatically\n// save all attachments to the specified directory\n$mail = $mailbox-\u003egetMail($mailsIds[0]);\n\n// Show, if $mail has one or more attachments\necho \"\\nMail has attachments? \";\nif($mail-\u003ehasAttachments()) {\n\techo \"Yes\\n\";\n} else {\n\techo \"No\\n\";\n}\n\n// Print all information of $mail\nprint_r($mail);\n\n// Access arbitrary headers without adding custom properties to the library\n$originMessageId = $mail-\u003egetHeader('Origin-MessageID');\n$receivedHeaders = $mail-\u003egetHeaders('Received');\n\n// Print all attachements of $mail\necho \"\\n\\nAttachments:\\n\";\nprint_r($mail-\u003egetAttachments());\n```\n\n`searchMailbox()` delegates criteria evaluation to PHP's IMAP extension and the IMAP server behind it. This library includes a fallback for simple `SEEN ... SINCE ...` searches because some `ext-imap` / server combinations do not immediately return messages marked as seen earlier on the same day. More complex `imap_search()` behavior still depends on the underlying IMAP implementation.\n\nMethod `imap()` allows to call any [PHP IMAP function](https://www.php.net/manual/ref.imap.php) in a context of the instance. Example:\n\n```php\n// Call imap_check() - see http://php.net/manual/function.imap-check.php\n$info = $mailbox-\u003eimap('check');\n\n\n// Show current time for the mailbox\n$currentServerTime = isset($info-\u003eDate) \u0026\u0026 $info-\u003eDate ? date('Y-m-d H:i:s', strtotime($info-\u003eDate)) : 'Unknown';\n\necho $currentServerTime;\n```\n\nSome request require much time and resources:\n\n```php\n// If you don't need to grab attachments you can significantly increase performance of your application\n$mailbox-\u003esetAttachmentsIgnore(true);\n\n// get the list of folders/mailboxes\n$folders = $mailbox-\u003egetMailboxes('*');\n\n// loop through mailboxs\nforeach($folders as $folder) {\n\n\t// switch to particular mailbox\n\t$mailbox-\u003eswitchMailbox($folder['fullpath']);\n\n\t// search in particular mailbox\n\t$mails_ids[$folder['fullpath']] = $mailbox-\u003esearchMailbox('SINCE \"1 Jan 2018\" BEFORE \"28 Jan 2018\"');\n}\n\nprint_r($mails_ids);\n```\n\n### Upgrading from 3.x\n\nPrior to 3.1, `Mailbox` used a \"magic\" method (`Mailbox::imap()`), with the\nclass `Imap` now performing it's purpose to call many `imap_*` functions with\nautomated string encoding/decoding of arguments and return values:\n\nBefore:\n\n```php\n    public function checkMailbox()\n    {\n        return $this-\u003eimap('check');\n    }\n```\n\nAfter:\n\n```php\n    public function checkMailbox(): object\n    {\n        return Imap::check($this-\u003egetImapStream());\n    }\n```\n\n### Recommended\n\n* Google Chrome extension [PHP Console](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef)\n* Google Chrome extension [JavaScript Errors Notifier](https://chrome.google.com/webstore/detail/javascript-errors-notifie/jafmfknfnkoekkdocjiaipcnmkklaajd)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarbushin%2Fphp-imap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarbushin%2Fphp-imap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarbushin%2Fphp-imap/lists"}