amirsanni/php-ews-wrapper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

amirsanni/php-ews-wrapper

Composer 安装命令:

composer require amirsanni/php-ews-wrapper

包简介

A simple wrapper around jamesiarmes/php-ews library

README 文档

README

This is a library for communicating with Exchange Web Service. It provides a very simple and easy to use API, leveraging on jamesiarmes/php-ews library.

Installation

composer require amirsanni/php-ews-wrapper

Features

  • Send Email
  • Create Draft
  • Send Messages in Draft
  • Get Inbox Messages
  • Get Unread Messages
  • Change Message Read Status
  • Delete Message
  • Get Sent Items
  • Get Outbox Items
  • Get Draft Items
  • Get Contacts
  • Get Deleted Messages
  • Get Archived Messages
  • Get Messages in Favorites Folder
  • Get Junk Messages
  • Get Tasks
  • Get Conversation History
  • Get Folders List
  • Create event

How to use

Instantiate

use amirsanni\phpewswrapper\PhpEwsWrapper;

$ews = new PhpEwsWrapper('accessToken', 'email', 'optionalPassword', 'optionalServerAddress', 'optionalVersion');

Note:

  • Password is required if accessToken is not provided.
  • Access token is preferred because password authentication won't work unless for on-premise installations.
  • Server address defaults to outlook.office365.com

Supported Versions: 2007, 2009, 2010, 2013, 2016. Defaults to 2016.

Send Email

$ews->mail->sender_name = "John Doe";
$ews->mail->subject = "Test email";
$ews->mail->body = "This is a test email";
$ews->mail->recipient = 'abc@example.com'; //['abc@xyz.com', 'abc@example.com']
$ews->mail->recipient_name = "Amir Sanni";
$ews->mail->cc = ['abc@xyz.com', 'abc@example.com']; //'abc@example.com'
$ews->mail->bcc = 'abc@example.com'; //['abc@xyz.com', 'abc@example.com']
$ews->mail->attach = ['file1', 'file2', 'file3']; //'file'
$ews->mail->send_as_email = 'abc@xyz.com';//to send as another user, not the logged in user. Optional

$ews->mail->send();  

Create Draft

$ews->mail->sender_name = "Foo Bar";
$ews->mail->subject = "Test email";
$ews->mail->body = "This is a test email";
$ews->mail->recipient = 'abc@example.com'; //['abc@xyz.com', 'john.doe@example.com']
$ews->mail->recipient_name = "Amir Sanni";
$ews->mail->cc = ['abc@xyz.com', 'abc@example.com']; //'abc@example.com'
$ews->mail->bcc = 'abc@example.com'; //['abc@xyz.com', 'abc@example.com']
$ews->mail->attach = ['file1', 'file2', 'file3']; //'file'
$ews->mail->send_as_email = 'abc@xyz.com';

$ews->mail->save();  

Get Messages

$ews->mail->limit = 30;

//each of the methods takes an optional page_number of type int
$ews->mail->inbox();//Messages in inbox
$ews->mail->sent(3);
$ews->mail->draft();
$ews->mail->outbox(1);
$ews->mail->conversationHistory();
$ews->mail->favourites();//favorites() will also work
$ews->mail->junk();
$ews->mail->deleted();
$ews->mail->archived();

Get Contacts

$ews->contacts->limit = 10;

//Method takes an optional 'pageNumber' of type int
$res = $ews->contacts->get(); 

Get Tasks

$ews->tasks->limit = 10;

//Method takes an optional 'pageNumber' of type int
$res = $ews->tasks->get();  

Send Message From Draft

$ews->mail->limit = 30;

$draft_items = $ews->mail->draft();

if($draft_items->status === 1 && $draft_items->messages){
    foreach($draft_items->messages as $item){
        $ews->mail->send($item->message_id, $item->change_key);
    }
}

Change Message Read Status

$ews->mail->limit = 30;

$items = $ews->mail->inbox();//$ews->mail->unread()

if($items->status === 1 && $items->messages){
    foreach($items->messages as $item){
        $ews->mail->markAsRead($item->message_id, $item->change_key);
        //$ews->mail->markAsUnread($item->message_id, $item->change_key);
    }
}

Delete Messages

$ews->mail->limit = 30;

$items = $ews->mail->inbox();

if($items->status === 1 && $items->messages){
    foreach($items->messages as $item){
        $ews->mail->delete($item->message_id);
    }
}

Create Calendar Event

$ews->events->event_start = '2019-06-27 08:00:00';
$ews->events->event_end = '2019-06-27 10:00:00';
$ews->events->timezone = 'Africa/Lagos';//Any PHP Timezone
$ews->events->location = 'Fabac, VI, Lagos';
$ews->events->subject = 'Test';
$ews->events->event_body = 'This is a test event';
$ews->events->invitees = [
    ['name'=>'John Doe', 'email'=>'john.doe@example.com'],
    ['name'=>'Foo Bar', 'email'=>'foo.bar@example.com']
];

$res = $ews->events->create();

Check out the examples folder for more usage information

amirsanni/php-ews-wrapper 适用场景与选型建议

amirsanni/php-ews-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.67k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2019 年 04 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-02