mailcraft-laravel maintained by mail-craft
mail-craft/mailcraft-laravel
Official Laravel integration for MailCraft — wraps mail-craft/mailcraft-php with a Mail transport, a facade, and config publishing.
Install
composer require mail-craft/mailcraft-laravel
Publish the config (optional — it works from env vars alone):
php artisan vendor:publish --tag=mailcraft-config
MAILCRAFT_API_KEY=sk_live_...
MAIL_MAILER=mailcraft
Usage
As a Mail transport (zero code changes)
With MAIL_MAILER=mailcraft set, every existing Mail::send(...) / Mailable / notification call routes through MailCraft automatically:
Mail::to('person@example.com')->send(new WelcomeEmail($user));
The package converts the Symfony MIME message Laravel builds into the structured fields MailCraft's API expects (from/to/subject/html/text/headers) — no raw-MIME endpoint required.
Using the client/facade directly
For anything beyond sending mail — contacts, campaigns, templates, domains, etc. — use the facade or inject the client:
use MailCraft\Laravel\Facades\MailCraft;
MailCraft::contacts()->upsert(email: 'person@example.com', firstName: 'Ada');
MailCraft::campaigns()->send($campaignId);
use MailCraft\MailCraft;
class SubscribeController
{
public function __invoke(MailCraft $mailcraft)
{
$mailcraft->contacts->upsert(email: request('email'));
}
}
Both styles reach the same underlying resources — see mail-craft/mailcraft-php's README for the full resource list.
Requirements
PHP 8.1+, Laravel 10, 11, 12, or 13.
License
MIT