mail-craft / mailcraft-laravel
Official Laravel integration for MailCraft — a Mail transport, facade, and config publishing on top of mail-craft/mailcraft-php.
Requires
- php: ^8.1
- illuminate/mail: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- mail-craft/mailcraft-php: ^0.1.0
- symfony/mailer: ^6.0|^7.0|^8.0
Requires (Dev)
- orchestra/testbench: ^9.0|^10.0
- pestphp/pest: ^2.34
- phpstan/phpstan: ^1.11
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
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