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

ActiveLibrary

mailcraft/mailcraft-laravel
===========================

Official Laravel SDK for MailCraft — transactional email with AI-generated content

01↑2900%PHP

Since Mar 28Pushed 1mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

mailcraft-laravel
=================

[](#mailcraft-laravel)

Official Laravel SDK for [MailCraft](https://github.com/mailcraft-cloud/mailcraft) — open source transactional email with AI-generated content.

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

[](#installation)

```
composer require mailcraft/mailcraft-laravel
```

Laravel auto-discovers the service provider and facade.

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

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --tag=mailcraft-config
```

Add your API key to `.env`:

```
MAILCRAFT_API_KEY=mc_your_api_key_here
```

If self-hosting:

```
MAILCRAFT_BASE_URL=https://your-mailcraft-instance.com
```

Usage
-----

[](#usage)

### Fluent API (recommended)

[](#fluent-api-recommended)

```
use MailCraft\Facades\MailCraft;

MailCraft::create('welcome')
    ->to('john@example.com')
    ->data(['name' => 'John', 'plan' => 'Pro'])
    ->prompt('Mention dedicated support')
    ->action('Get Started', 'https://app.example.com')
    ->action('View Docs', 'https://docs.example.com', 'secondary')
    ->send();
```

### Classic API

[](#classic-api)

```
$result = MailCraft::send([
    'type'    => 'welcome',
    'to'      => 'john@example.com',
    'data'    => ['name' => 'John', 'plan' => 'Pro'],
    'prompt'  => 'Mention dedicated support',
    'actions' => [
        ['label' => 'Get Started', 'url' => 'https://app.example.com'],
    ],
]);
```

### With Dependency Injection

[](#with-dependency-injection)

```
use MailCraft\MailCraftClient;

class WelcomeController extends Controller
{
    public function __construct(private MailCraftClient $mail) {}

    public function send(): void
    {
        $this->mail->create('welcome')
            ->to('john@example.com')
            ->data(['name' => 'John'])
            ->send();
    }
}
```

### Without Laravel (standalone)

[](#without-laravel-standalone)

```
use MailCraft\MailCraftClient;

$client = new MailCraftClient('mc_your_api_key');

$client->create('welcome')
    ->to('john@example.com')
    ->data(['name' => 'John'])
    ->send();
```

Fluent Builder Methods
----------------------

[](#fluent-builder-methods)

MethodDescription`->to($email)`Set recipient email`->data($array)`Set dynamic template data`->prompt($string)`Steer AI content generation`->action($label, $url, $style?)`Add a CTA button (call multiple times)`->actions($array)`Set all actions at once`->send()`Send the email, returns `['id' => ..., 'status' => ...]`Options (Classic API)
---------------------

[](#options-classic-api)

FieldTypeRequiredDescription`type``string`YesEmail type: `'welcome'`, `'invoice'`, `'password-reset'`, etc.`to``string`YesRecipient email address`data``array`NoTemplate variables`prompt``string`NoAI content instructions`actions``array`NoCTA buttons: `[['label' => ..., 'url' => ..., 'style' => ...]]`Response
--------

[](#response)

```
['id' => 'log_abc123', 'status' => 'sent']
// status: "sent" | "failed" | "fallback"
```

Error Handling
--------------

[](#error-handling)

```
use MailCraft\Facades\MailCraft;
use MailCraft\MailCraftException;

try {
    MailCraft::create('welcome')
        ->to('john@example.com')
        ->send();
} catch (MailCraftException $e) {
    $e->getStatusCode(); // 401, 400, 502, etc.
    $e->getMessage();    // "Invalid API key"
    $e->getBody();       // Parsed response body
}
```

Self-Hosted
-----------

[](#self-hosted)

```
MAILCRAFT_BASE_URL=https://mail.internal.example.com
```

Or pass directly:

```
$client = new MailCraftClient('mc_your_key', 'https://mail.internal.example.com');
```

License
-------

[](#license)

MIT

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance60

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/177a31f7715aa823cedb9a9fa2664012c39e4d4022ea55ca5f47fa87200ab3e7?d=identicon)[otarmames](/maintainers/otarmames)

---

Top Contributors

[![mrtunii](https://avatars.githubusercontent.com/u/15321788?v=4)](https://github.com/mrtunii "mrtunii (4 commits)")

### Embed Badge

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

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

PHPackages © 2026

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