承接 webklex/php-imap 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

webklex/php-imap

Composer 安装命令:

composer require webklex/php-imap

包简介

PHP IMAP client

README 文档

README

Latest release on Packagist Latest prerelease on Packagist Software License Total Downloads Hits Discord Snyk

Description

PHP-IMAP is a wrapper for common IMAP communication without the need to have the php-imap module installed / enabled. The protocol is completely integrated and therefore supports IMAP IDLE operation and the "new" oAuth authentication process as well. You can enable the php-imap module in order to handle edge cases, improve message decoding quality and is required if you want to use legacy protocols such as pop3.

Official documentation: php-imap.com

Laravel wrapper: webklex/laravel-imap

Discord: discord.gg/rd4cN9h6

Table of Contents

Documentations

Compatibility

Version PHP 5.6 PHP 7 PHP 8
v6.x / / X
v5.x / / X
v4.x / X X
v3.x / X /
v2.x X X /
v1.x X / /

Basic usage example

This is a basic example, which will echo out all Mails within all imap folders and will move every message into INBOX.read. Please be aware that this should not be tested in real life and is only meant to give an impression on how things work.

use Webklex\PHPIMAP\ClientManager;

require_once "vendor/autoload.php";

$cm = new ClientManager('path/to/config/imap.php');

/** @var \Webklex\PHPIMAP\Client $client */
$client = $cm->account('account_identifier');

//Connect to the IMAP Server
$client->connect();

//Get all Mailboxes
/** @var \Webklex\PHPIMAP\Support\FolderCollection $folders */
$folders = $client->getFolders();

//Loop through every Mailbox
/** @var \Webklex\PHPIMAP\Folder $folder */
foreach($folders as $folder){

    //Get all Messages of the current Mailbox $folder
    /** @var \Webklex\PHPIMAP\Support\MessageCollection $messages */
    $messages = $folder->messages()->all()->get();
    
    /** @var \Webklex\PHPIMAP\Message $message */
    foreach($messages as $message){
        echo $message->getSubject().'<br />';
        echo 'Attachments: '.$message->getAttachments()->count().'<br />';
        echo $message->getHTMLBody();
        
        //Move the current Message to 'INBOX.read'
        if($message->move('INBOX.read') == true){
            echo 'Message has been moved';
        }else{
            echo 'Message could not be moved';
        }
    }
}

Sponsors

elb-BIT Feline

Testing

To run the tests, please execute the following command:

composer test

Quick-Test / Static Test

To disable all test which require a live mailbox, please copy the phpunit.xml.dist to phpunit.xml and adjust the configuration:

<php>
    <env name="LIVE_MAILBOX" value="false"/>
</php>

Full-Test / Live Mailbox Test

To run all tests, you need to provide a valid imap configuration.

To provide a valid imap configuration, please copy the phpunit.xml.dist to phpunit.xml and adjust the configuration:

<php>
    <env name="LIVE_MAILBOX" value="true"/>
    <env name="LIVE_MAILBOX_DEBUG" value="true"/>
    <env name="LIVE_MAILBOX_HOST" value="mail.example.local"/>
    <env name="LIVE_MAILBOX_PORT" value="993"/>
    <env name="LIVE_MAILBOX_VALIDATE_CERT" value="false"/>
    <env name="LIVE_MAILBOX_QUOTA_SUPPORT" value="true"/>
    <env name="LIVE_MAILBOX_ENCRYPTION" value="ssl"/>
    <env name="LIVE_MAILBOX_USERNAME" value="root@example.local"/>
    <env name="LIVE_MAILBOX_PASSWORD" value="foobar"/>
</php>

The test account should not contain any important data, as it will be deleted during the test. Furthermore, the test account should be able to create new folders, move messages and should not be used by any other application during the test.

It's recommended to use a dedicated test account for this purpose. You can use the provided Dockerfile to create an imap server used for testing purposes.

Build the docker image:

cd .github/docker

docker build -t php-imap-server .

Run the docker image:

docker run --name imap-server -p 993:993 --rm -d php-imap-server

Stop the docker image:

docker stop imap-server

Known issues

Error Solution
Kerberos error: No credentials cache file found (try running kinit) (...) Uncomment "DISABLE_AUTHENTICATOR" inside your config and use the legacy-imap protocol

Support

If you encounter any problems or if you find a bug, please don't hesitate to create a new issue. However, please be aware that it might take some time to get an answer. Off-topic, rude or abusive issues will be deleted without any notice.

If you need commercial support, feel free to send me a mail at github@webklex.com.

A little notice

If you write source code in your issue, please consider to format it correctly. This makes it so much nicer to read
and people are more likely to comment and help :)

```php

echo 'your php code...';

```

will turn into:

echo 'your php code...'; 

Features & pull requests

Everyone can contribute to this project. Every pull request will be considered, but it can also happen to be declined.
To prevent unnecessary work, please consider to create a feature issue
first, if you're planning to do bigger changes. Of course, you can also create a new feature issue if you're just wishing a feature ;)

Alternatives & Different Flavors

This library and especially the code flavor It's written in, is certainly not for everyone. If you are looking for a different approach, you might want to check out the following libraries:

Change log

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security related issues, please email github@webklex.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

webklex/php-imap 适用场景与选型建议

webklex/php-imap 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.86M 次下载、GitHub Stars 达 444, 最近一次更新时间为 2018 年 08 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「mail」 「imap」 「pop3」 「php-imap」 「webklex」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 webklex/php-imap 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 webklex/php-imap 我们能提供哪些服务?
定制开发 / 二次开发

基于 webklex/php-imap 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6.86M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 446
  • 点击次数: 24
  • 依赖项目数: 27
  • 推荐数: 3

GitHub 信息

  • Stars: 444
  • Watchers: 14
  • Forks: 190
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-08-13