PHPackages                             o323/nylas-php - 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. [API Development](/categories/api)
4. /
5. o323/nylas-php

ActiveLibrary[API Development](/categories/api)

o323/nylas-php
==============

PHP wrapper for the Nylas API

0.1.2(10y ago)3208MITPHPPHP &gt;=5.4

Since Jan 20Pushed 10y ago1 watchersCompare

[ Source](https://github.com/O323/nylas-php)[ Packagist](https://packagist.org/packages/o323/nylas-php)[ RSS](/packages/o323-nylas-php/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

Nylas PHP
---------

[](#nylas-php)

PHP bindings for the Nylas REST API

Installation
------------

[](#installation)

You can install the library by running:

```
composer require o323/nylas-php
```

Usage
-----

[](#usage)

The Nylas REST API uses server-side (three-legged) OAuth, and this library provides convenience methods to simplify the OAuth process. Here's how it works:

1. You redirect the user to our login page, along with your App Id and Secret
2. Your user logs in
3. She is redirected to a callback URL of your own, along with an access code
4. You use this access code to get an authorization token to the API

For more information about authenticating with Nylas, visit the [Developer Documentation](https://www.nylas.com/docs/gettingstarted-hosted#authenticating).

In practice, the Nylas REST API client simplifies this down to two steps.

Auth
----

[](#auth)

**index.php**

```
$client = new Nylas(CLIENT, SECRET);
$redirect_url = 'http://localhost:8080/login_callback.php';
$get_auth_url = $client->createAuthURL($redirect_url);

// redirect to Nylas auth server
header("Location: ".$get_auth_url);
```

**login\_callback.php**

```
$access_code = $_GET['code'];
$client = new Nylas(CLIENT, SECRET);
$get_token = $client->getAuthToken($access_code);

// save token in session
$_SESSION['access_token'] = $get_token;
```

Fetching Account Information
----------------------------

[](#fetching-account-information)

```
$client = new Nylas(CLIENT, SECRET, TOKEN);
$account = $client->account();

echo $account->email_address;
echo $account->provider;
```

Fetching Threads
----------------

[](#fetching-threads)

```
$client = new Nylas(CLIENT, SECRET, TOKEN);

// Fetch the first thread
$first_thread = $client->threads()->first();
echo $first_thread->id;

// Fetch first 2 latest threads
$two_threads = $client->threads()->all(2);
foreach($two_threads as $thread) {
    echo $thread->id;
}

// List all threads with 'ben@nylas.com'
$search_criteria = array("any_email" => "ben@nylas.com");
$get_threads = $client->threads()->where($search_criteria)->items()
foreach($get_threads as $thread) {
    echo $thread->id;
}
```

Working with Threads
--------------------

[](#working-with-threads)

```
// List thread participants
foreach($thead->participants as $participant) {
    echo $participant->email;
    echo $participant->name;
}

// Mark as Read
$thread->markAsRead();

// Mark as Seen
$thread->markAsSeen();

// Archive
$thread->archive();

// Unarchive
$thread->unarchive();

// Trash
$thread->trash();

// Star
$thread->star();

// Unstar
$thread->unstar();

// Add or remove arbitrary tags
$to_add = array('cfa1233ef123acd12');
$to_remove = array('inbox');
$thread->addTags($to_add);
$thread->removeTags($to_remove);

// Listing messages
foreach($thread->messages()->items() as $message) {
    echo $message->subject;
    echo $message->body;
}
```

Working with Files
------------------

[](#working-with-files)

```
$client = new Nylas(CLIENT, SECRET, TOKEN);

$file_path = '/var/my/folder/test_file.pdf';
$upload_resp = $client->files()->create($file_path);
echo $upload_resp->id;
```

Working with Drafts
-------------------

[](#working-with-drafts)

```
$client = new Nylas(CLIENT, SECRET, TOKEN);

$person_obj = new \Nylas\Models\Person('Kartik Talwar', 'kartik@nylas.com');
$message_obj = array( "to" => array($person_obj),
                      "subject" => "Hello, PHP!",
                      "body" => "Test  message");

$draft = $client->drafts()->create($message_obj);
$send_message = $draft->send();
echo $send_message->id;
```

Working with Events
-------------------

[](#working-with-events)

```
$client = new Nylas(CLIENT, SECRET, TOKEN);
$calendars = $client->calendars()->all();

$calendar = null;
foeach($calendars as $i) {
  if(!$i->read_only) {
    $calendar = $i;
  }
}

$person_obj = new \Nylas\Models\Person('Kartik Talwar', 'kartik@nylas.com');
$calendar_obj = array("title" => "Important Meeting",
                      "location" => "Nylas HQ",
                      "participants" => array($person_obj),
                      "calendar_id" => $calendar->id,
                      "when" => array("start_time" => time(),
                                      "end_time" => time() + (30*60)));
// create event
$event = $client->events()->create($calendar_obj);
echo $event->id;

// update
$event = $event->update(array("location" => "Meeting room #1"));

// delete event
$event->delete();
// delete event (alternate)
$remove = $client->events()->find($event->id)->delete();
```

Open-Source Sync Engine
-----------------------

[](#open-source-sync-engine)

The [Nylas Sync Engine](http://github.com/nylas/sync-engine) is open-source, and you can also use the PHP library with the open-source API. Since the open-source API provides no authentication or security, connecting to it is simple. When you instantiate the Nylas object, provide null for the App ID, App Secret, and API Token, and pass the fully-qualified address of your copy of the sync engine:

```
$client = new Nylas(CLIENT, SECRET, TOKEN, 'http://localhost:5555/');
```

Contributing
------------

[](#contributing)

We'd love your help making Nylas better. Join the Google Group for project updates and feature discussion. We also hang out in `#nylas` on [irc.freenode.net](irc.freenode.net), or you can email .

Please sign the Contributor License Agreement before submitting pull requests. (It's similar to other projects, like NodeJS or Meteor.)

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.8% 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 ~0 days

Total

3

Last Release

3795d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16590039?v=4)[O323 (Omega323)](/maintainers/o323)[@O323](https://github.com/O323)

---

Top Contributors

[![KartikTalwar](https://avatars.githubusercontent.com/u/461702?v=4)](https://github.com/KartikTalwar "KartikTalwar (36 commits)")[![duxet](https://avatars.githubusercontent.com/u/821707?v=4)](https://github.com/duxet "duxet (5 commits)")[![wmozejko](https://avatars.githubusercontent.com/u/16381045?v=4)](https://github.com/wmozejko "wmozejko (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/o323-nylas-php/health.svg)

```
[![Health](https://phpackages.com/badges/o323-nylas-php/health.svg)](https://phpackages.com/packages/o323-nylas-php)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.6M932](/packages/statamic-cms)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k34](/packages/neuron-core-neuron-ai)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)[fschmtt/keycloak-rest-api-client-php

PHP client to interact with Keycloak's Admin REST API.

49108.6k2](/packages/fschmtt-keycloak-rest-api-client-php)

PHPackages © 2026

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