PHPackages                             amirsanni/php-ews-wrapper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. amirsanni/php-ews-wrapper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

amirsanni/php-ews-wrapper
=========================

A simple wrapper around jamesiarmes/php-ews library

v1.2(3y ago)71.6k↓33.3%[1 PRs](https://github.com/amirsanni/php-ews-wrapper/pulls)MITPHP &gt;=7.0

Since Jun 28Compare

[ Source](https://github.com/amirsanni/php-ews-wrapper)[ Packagist](https://packagist.org/packages/amirsanni/php-ews-wrapper)[ RSS](/packages/amirsanni-php-ews-wrapper/feed)WikiDiscussions Synced 1mo ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

php-ews-wrapper
===============

[](#php-ews-wrapper)

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
============

[](#installation)

```
composer require amirsanni/php-ews-wrapper

```

Features
========

[](#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
==========

[](#how-to-use)

### Instantiate

[](#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
----------

[](#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
------------

[](#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
------------

[](#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
------------

[](#get-contacts)

```
$ews->contacts->limit = 10;

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

```

Get Tasks
---------

[](#get-tasks)

```
$ews->tasks->limit = 10;

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

```

Send Message From Draft
-----------------------

[](#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
--------------------------

[](#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
---------------

[](#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
---------------------

[](#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

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~304 days

Total

5

Last Release

1299d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f9c7f32727efeed7d3a497957e65f20b29b9c08fb9342fdd5f954c1b06158e8?d=identicon)[amirsanni](/maintainers/amirsanni)

---

Top Contributors

[![amirsanni](https://avatars.githubusercontent.com/u/6107185?v=4)](https://github.com/amirsanni "amirsanni (129 commits)")[![athornstrom](https://avatars.githubusercontent.com/u/161473969?v=4)](https://github.com/athornstrom "athornstrom (1 commits)")

---

Tags

phpMicrosoft ExchangeewsExchange Web ServicePhpEws

### Embed Badge

![Health badge](/badges/amirsanni-php-ews-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/amirsanni-php-ews-wrapper/health.svg)](https://phpackages.com/packages/amirsanni-php-ews-wrapper)
```

###  Alternatives

[garethp/php-ews

A PHP Library to interact with the Exchange SOAP service

113610.3k4](/packages/garethp-php-ews)[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
