PHPackages                             sumacrm/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. sumacrm/nylas-php

ActiveLibrary[API Development](/categories/api)

sumacrm/nylas-php
=================

PHP wrapper for the Nylas API (Adapted for lanlin).

2.2.0(7y ago)192MITPHPPHP &gt;=5.6

Since Oct 11Pushed 7y ago1 watchersCompare

[ Source](https://github.com/samuelfa/nylas-php)[ Packagist](https://packagist.org/packages/sumacrm/nylas-php)[ RSS](/packages/sumacrm-nylas-php/feed)WikiDiscussions master Synced 2d ago

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

Nylas PHP
---------

[](#nylas-php)

PHP bindings for the Nylas REST API

Modification
------------

[](#modification)

I fork this project from lanlin/nylas-php, because i find the original package only support guzzle 5 and lanlin package only supports PHP 7. Now i made some change, so it can support guzzle &gt;6.0.

Be care, there maybe has some bugs that i have not found yet.

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

[](#installation)

You can install my fork library with composer.

```
composer require "sumacrm/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.

Options Parameters
------------------

[](#options-parameters)

```
$OPTIONS =
[
    'app_id'     => 'your app id',
    'app_secret' => 'your app secret',
    'app_server' => 'default https://api.nylas.com/',

    'token'      => 'token',
    'debug'      => 'true or false',
];
```

Auth
----

[](#auth)

**index.php**

```
$client = new Nylas($OPTIONS);

$redirect_url = 'http://localhost:8080/login_callback.php';

$get_auth_url = $client->oauth($OPTIONS)->createAuthURL($redirect_url);

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

**login\_callback.php**

```
$access_code = $_GET['code'];

$client = new Nylas($OPTIONS);

$get_token = $client->oauth($OPTIONS)->getAuthToken($access_code);

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

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

[](#fetching-threads)

```
// init client!
$client = new Nylas($OPTIONS);

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

echo $first_thread->id;

// Fetch first 2 latest threads
$two_threads = $client->threads($OPTIONS)->all(2);

// Fetch threads from offset 30, and limit 50
$part_threads = $client->threads($OPTIONS)->part(30, 50);

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($OPTIONS)->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;
}

// Unread or Read
$thread->unread($id, $unread = false);

// Move to folder
$thread->move($id, $target_id, $type = 'folder');

// Star
$thread->starred($id, $starred = true);

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

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

[](#working-with-files)

```
$client = new Nylas($OPTIONS);

$file_path = '/var/my/folder/test_file.pdf';

$upload_resp = $client->files($OPTIONS)->create($file_path);

echo $upload_resp->id;
```

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

[](#working-with-drafts)

```
$client = new Nylas($OPTIONS);

$message =
[
     "to"      =>
     [
         ["name" => "Nylas", "email" => "nylas@nylas.com"],
         ["name" => "Goole", "email" => "goole@google.com"],
     ],
     "subject" => "Hello, PHP!",
     "body"    => "Test  message"
];

$draft = $client->drafts($OPTIONS)->create($message_obj);

$send_message = $draft->send( ['id' => $draft->id] );

echo $send_message->id;
```

Working with Send Directly
--------------------------

[](#working-with-send-directly)

Carefully, send directly is diffrent from create a draft and then send it above.

```
$client = new Nylas($OPTIONS);

$message =
[
     "to"      =>
     [
         ["name" => "Nylas", "email" => "nylas@nylas.com"],
         ["name" => "Goole", "email" => "goole@google.com"],
     ],
     "subject" => "Hello, PHP!",
     "body"    => "Test  message"
];

$draft = $client->drafts($OPTIONS)->send($message_obj);
```

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

[](#working-with-events)

```
$client = new Nylas($OPTIONS);

$calendars = $client->calendars($OPTIONS)->all();

$calendar = null;

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

$calendar_data =
[
    "title"        => "Important Meeting",
    "location"     => "Nylas HQ",
    "participants" => [ ["name" => "nylas", "email" => "nylas@nylas.com"] ]
    "calendar_id"  => $calendar->id,
    "when"         => array("start_time" => time(),
    "end_time"     => time() + (30*60))
];

// create event
$event = $client->events($OPTIONS)->create($calendar_data);

echo $event->id;

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

// delete event
$event->delete();

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

Webhooks Signature Verification
-------------------------------

[](#webhooks-signature-verification)

```
$client = new Nylas($OPTIONS);
$is_valid = $client->xSignatureVerification($code, $data, $app_secret)
```

End
---

[](#end)

This nylas-php project is forked by  and by  (support for PHP 5.6)

it's not the official version. The official version has many bugs.

And not suport guzzle &gt;6.0 yet. So i fork it, and made many modification.

Surely there's bugs in my fork, but i not have much time on this.

So, help fix these bugs, request pulls are welcome.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 63.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 ~20 days

Recently: every ~35 days

Total

15

Last Release

2907d ago

Major Versions

1.0.0 → 2.0.02017-10-17

PHP version history (2 changes)1.0.0PHP &gt;=7.0

2.2.0PHP &gt;=5.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4594902?v=4)[Samuel Fernández Amorós](/maintainers/samuelfa)[@samuelfa](https://github.com/samuelfa)

---

Top Contributors

[![lanlin](https://avatars.githubusercontent.com/u/3468024?v=4)](https://github.com/lanlin "lanlin (60 commits)")[![KartikTalwar](https://avatars.githubusercontent.com/u/461702?v=4)](https://github.com/KartikTalwar "KartikTalwar (34 commits)")

### Embed Badge

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

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

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.6M948](/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.1k36](/packages/neuron-core-neuron-ai)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.5M7](/packages/avalara-avataxclient)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1933.1k4](/packages/aimeos-prisma)

PHPackages © 2026

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