承接 medeirosrafael/laravel-imap 相关项目开发

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

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

medeirosrafael/laravel-imap

Composer 安装命令:

composer require medeirosrafael/laravel-imap

包简介

Laravel IMAP client (forked)

README 文档

README

Latest Version on Packagist Software License Build Status Total Downloads

Install

Via Composer

$ composer require webklex/laravel-imap

Setup

Add the service provider to the providers array in config/app.php.

'providers' => [
    Webklex\IMAP\Providers\LaravelServiceProvider::class,
];

If you are planning to use a single account, you might want to add the following to your .env file.

IMAP_HOST=somehost.com
IMAP_PORT=993
IMAP_ENCRYPTION=ssl
IMAP_VALIDATE_CERT=true
IMAP_USERNAME=root@example.com
IMAP_PASSWORD=secret

The following encryption methods are supported:

false   - Disable encryption 
ssl     - Use SSL
tls     - Use TLS

Publishing

You can publish everything at once

php artisan vendor:publish --provider="Webklex\IMAP\Providers\LaravelServiceProvider"

Access the IMAP Client by its Facade \Webklex\IMAP\Facades\Client. Therefor you might want to add an alias to the aliases array within the config/app.php file.

'aliases' => [
    'Client' => Webklex\IMAP\Facades\Client::class
];

Usage

This library is designed to handle the native php imap functions more easily and to be able to integrate this package within your current laravel installation.

Here 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 ben tested in real live but it gives an impression on how things work.

use Webklex\IMAP\Client;

$oClient = new Client([
    'host'          => 'somehost.com',
    'port'          => 993,
    'encryption'    => 'ssl',
    'validate_cert' => true,
    'username'      => 'username',
    'password'      => 'password',
]);

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

//Get all Mailboxes
$aMailboxes = $oClient->getFolders();

//Loop through every Mailbox
/** @var \Webklex\IMAP\Folder $oMailbox */
foreach($aMailboxes as $oMailbox){

    //Get all Messages of the current Mailbox
    /** @var \Webklex\IMAP\Message $oMessage */
    foreach($oMailbox->getMessages() as $oMessage){
        echo $oMessage->subject.'<br />';
        echo 'Attachments: '.$oMessage->getAttachments()->count().'<br />';
        echo $oMessage->getHTMLBody(true);
        
        //Move the current Message to 'INBOX.read'
        if($oMessage->moveToFolder('INBOX.read') == true){
            echo 'Message has ben moved';
        }else{
            echo 'Message could not be moved';
        }
    }
}

If you use the Facade \Webklex\IMAP\Facades\Client please select an account first:

use Webklex\IMAP\Facades\Client;

$oClient = Webklex\IMAP\Facades\Client::account('default');
$oClient->connect();

You can define your accounts inside the config/imap.php file:

'accounts' => [ 
    'default' => [
        'host'  => env('IMAP_HOST', 'localhost'),
        'port'  => env('IMAP_PORT', 993),
        'encryption'    => env('IMAP_ENCRYPTION', 'ssl'),
        'validate_cert' => env('IMAP_VALIDATE_CERT', true),
        'username' => env('IMAP_USERNAME', 'root@example.com'),
        'password' => env('IMAP_PASSWORD', ''),
    ], 
    'gmail' => [.. ]
]

Documentation

\Webklex\IMAP\Client

Method Arguments Return Description
setConfig array $config self Set the Client configuration. Take a look at config/imap.php for more inspiration.
setReadOnly bool $readOnly self Set read only property and reconnect if it's necessary.
isReadOnly bool Determine if connection is in read only mode.
isConnected bool Determine if connection was established.
checkConnection Determine if connection was established and connect if not.
connect int $attempts Connect to server.
disconnect Disconnect from server.
getFolders bool $hierarchical, string or null $parent_folder array Get folders list. If hierarchical order is set to true, it will make a tree of folders, otherwise it will return flat array.
openFolder \Webklex\IMAP\Folder $folder Open a given folder.
createFolder string $name Create a new folder.
getMessages \Webklex\IMAP\Folder $folder, string $criteria array Get messages from folder.
getQuota array Retrieve the quota level settings, and usage statics per mailbox
getQuotaRoot string $quota_root array Retrieve the quota settings per user
countMessages int Gets the number of messages in the current mailbox
countRecentMessages int Gets the number of recent messages in current mailbox
getAlerts array Returns all IMAP alert messages that have occurred
getErrors array Returns all of the IMAP errors that have occurred
getLastError string Gets the last IMAP error that occurred during this page request
expunge bool Delete all messages marked for deletion
checkCurrentMailbox object Check current mailbox

\Webklex\IMAP\Message

Method Arguments Return Description
delete Delete the current Message
restore Restore a deleted Message
copy string $mailbox, int $options Copy the current Messages to a mailbox
move string $mailbox, int $options Move the current Messages to a mailbox
moveToFolder string $mailbox Move the Message into an other Folder
hasTextBody Check if the Message has a text body
hasHTMLBody Check if the Message has a html body
getTextBody string Get the Message text body
getHTMLBody string Get the Message html body
getAttachments collection Get all message attachments

\Webklex\IMAP\Folder

Method Arguments Return Description
hasChildren bool Determine if folder has children.
setChildren array $children self Set children.
getMessages string $criteria array Get messages.
delete Delete the current Mailbox
move string $mailbox Move or Rename the current Mailbox
getStatus integer $options object Returns status information on a mailbox
appendMessage string $message, string $options, string $internal_date bool Append a string message to the current mailbox

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

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.

medeirosrafael/laravel-imap 适用场景与选型建议

medeirosrafael/laravel-imap 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 06 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 26
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 182
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-06