PHPackages                             polkachu/laravel-agentmail - 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. polkachu/laravel-agentmail

ActiveLibrary[API Development](/categories/api)

polkachu/laravel-agentmail
==========================

A Laravel package for Agentmail API integration

v1.0.0(2mo ago)10MITPHPPHP ^8.1CI passing

Since Mar 5Pushed 1mo agoCompare

[ Source](https://github.com/polkachu/laravel-agentmail)[ Packagist](https://packagist.org/packages/polkachu/laravel-agentmail)[ RSS](/packages/polkachu-laravel-agentmail/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

Laravel AgentMail
=================

[](#laravel-agentmail)

A Laravel package for interacting with the [AgentMail](https://agentmail.to) API. AgentMail provides programmatic email inboxes designed for AI agents.

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10, 11, or 12

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

[](#installation)

Install the package via Composer:

```
composer require polkachu/laravel-agentmail
```

The package auto-discovers its service provider via Laravel's package discovery.

Configuration
-------------

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --tag=agentmail
```

This creates `config/agentmail.php`. Add your API key to `.env`:

```
AGENTMAIL_API_KEY=your_api_key_here
```

By default the package points to `https://api.agentmail.to`. You can override this in `.env` if needed:

```
AGENTMAIL_BASE_URL=https://api.agentmail.to
```

Usage
-----

[](#usage)

All operations are accessed through the `Agentmail` facade.

### Inboxes

[](#inboxes)

#### List inboxes

[](#list-inboxes)

Returns an `InboxCollection` containing a Laravel `Collection` of `Inbox` objects.

```
use Polkachu\LaravelAgentmail\Facades\Agentmail;

$collection = Agentmail::inboxes()->list();

foreach ($collection->inboxes as $inbox) {
    echo $inbox->inboxId;
}
```

Paginate with `limit` and `pageToken`:

```
$collection = Agentmail::inboxes()->list(limit: 20);

// Fetch the next page
if ($collection->nextPageToken) {
    $nextPage = Agentmail::inboxes()->list(limit: 20, pageToken: $collection->nextPageToken);
}
```

#### Create an inbox

[](#create-an-inbox)

All parameters are optional. AgentMail will randomly generate a username if one is not provided.

```
$inbox = Agentmail::inboxes()->create(
    username: 'support',
    domain: 'agentmail.to',
    displayName: 'Support Agent',
    clientId: 'my-app-client-id',
);

echo $inbox->inboxId;      // e.g. "inbox_abc123"
echo $inbox->displayName;  // e.g. "Support Agent "
```

#### Get an inbox

[](#get-an-inbox)

```
$inbox = Agentmail::inboxes()->get('inbox_abc123');

echo $inbox->inboxId;
echo $inbox->podId;
echo $inbox->createdAt->toDateTimeString();
```

#### Update an inbox

[](#update-an-inbox)

Only the display name can be updated.

```
$inbox = Agentmail::inboxes()->update('inbox_abc123', 'New Name ');
```

#### Delete an inbox

[](#delete-an-inbox)

```
Agentmail::inboxes()->delete('inbox_abc123');
```

### The `Inbox` DTO

[](#the-inbox-dto)

All inbox operations return an `Inbox` object with the following properties:

PropertyTypeDescription`$inboxId``string`Unique inbox identifier`$podId``string`Pod the inbox belongs to`$displayName``?string`Display name string`$clientId``?string`Client identifier`$createdAt``Carbon`Creation timestamp`$updatedAt``Carbon`Last updated timestamp### The `InboxCollection` DTO

[](#the-inboxcollection-dto)

`Agentmail::inboxes()->list()` returns an `InboxCollection` with the following properties:

PropertyTypeDescription`$inboxes``Collection`List of inbox objects`$count``int`Number of inboxes returned`$limit``?int`Page size limit used`$nextPageToken``?string`Token to fetch the next page, or `null` if on the last pageError Handling
--------------

[](#error-handling)

Any non-2xx response throws an `AgentmailException`. It exposes:

- `$errorName` — the API's error name (e.g. `"NotFoundError"`, `"ValidationError"`)
- `getMessage()` — the human-readable error message from the API
- `getCode()` — the HTTP status code

```
use Polkachu\LaravelAgentmail\Exceptions\AgentmailException;

try {
    $inbox = Agentmail::inboxes()->get('inbox_does_not_exist');
} catch (AgentmailException $e) {
    echo $e->errorName;    // "NotFoundError"
    echo $e->getMessage(); // "Inbox not found."
    echo $e->getCode();    // 404
}
```

Testing
-------

[](#testing)

The package is tested with Pest PHP. To run the test suite:

```
composer test
```

In your own application tests, use Laravel's `Http::fake()` to mock AgentMail responses without making real API calls:

```
use Illuminate\Support\Facades\Http;
use Polkachu\LaravelAgentmail\Facades\Agentmail;

Http::fake([
    '*/v0/inboxes*' => Http::response([
        'count' => 1,
        'inboxes' => [[
            'inbox_id' => 'inbox_abc',
            'pod_id'   => 'pod_123',
            'created_at' => '2024-01-01T00:00:00Z',
            'updated_at' => '2024-01-02T00:00:00Z',
        ]],
    ]),
]);

$collection = Agentmail::inboxes()->list();

expect($collection->count)->toBe(1);
```

License
-------

[](#license)

[MIT](https://opensource.org/license/MIT)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance88

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.5% 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

Unknown

Total

1

Last Release

66d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/44f577cfd62eb88d724fe87bb9857c394666aed3bd7f345a50d35491aee49032?d=identicon)[PolkachuIntern](/maintainers/PolkachuIntern)

---

Top Contributors

[![PolkachuIntern](https://avatars.githubusercontent.com/u/96495393?v=4)](https://github.com/PolkachuIntern "PolkachuIntern (21 commits)")[![fern-api[bot]](https://avatars.githubusercontent.com/in/244756?v=4)](https://github.com/fern-api[bot] "fern-api[bot] (1 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/polkachu-laravel-agentmail/health.svg)

```
[![Health](https://phpackages.com/badges/polkachu-laravel-agentmail/health.svg)](https://phpackages.com/packages/polkachu-laravel-agentmail)
```

###  Alternatives

[spatie/laravel-query-builder

Easily build Eloquent queries from API requests

4.4k26.9M220](/packages/spatie-laravel-query-builder)[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[esign/laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API

69145.4k](/packages/esign-laravel-conversions-api)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

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