actengage/laravel-message-gears
MessageGears for Laravel
A Laravel package for the MessageGears API. Provides fluent Cloud and Accelerator API clients, a notification channel, and a Symfony Mailer transport.
Requirements
- PHP 8.3+
- Laravel 11, 12, or 13
Installation
composer require actengage/laravel-message-gears
The service provider is auto-discovered.
Configuration
Add your MessageGears credentials to config/services.php:
// config/services.php
return [
'messagegears' => [
'cloud' => [
'accountId' => env('MESSAGEGEARS_ACCOUNT_ID'),
'apiKey' => env('MESSAGEGEARS_API_KEY'),
],
'accelerator' => [
'accountId' => env('MESSAGEGEARS_ACCELERATOR_ACCOUNT_ID'),
'apiKey' => env('MESSAGEGEARS_ACCELERATOR_API_KEY'),
],
'campaign_id' => env('MESSAGEGEARS_CAMPAIGN_ID'),
],
];
Usage
Sending a Transactional Email Notification
use Actengage\MessageGears\Notifications\TransactionalEmail;
$notification = TransactionalEmail::make()
->campaignId('CAMPAIGN_ID')
->context([
'SubjectLine' => 'Welcome!',
'HtmlContent' => '<h1>Hello</h1>',
'TextContent' => 'Hello',
]);
$user->notify($notification);
Cloud API
The Cloud facade authenticates automatically and prepends the API version to URIs.
use Actengage\MessageGears\Facades\Cloud;
// Authenticated POST request
$response = Cloud::authenticate()->post('campaign/transactional/CAMPAIGN_ID', [
'json' => [
'accountId' => 'ACCOUNT_ID',
'recipient' => [
'data' => ['EmailAddress' => 'user@example.com'],
'format' => 'JSON',
],
],
]);
Accelerator API
use Actengage\MessageGears\Facades\Accelerator;
$response = Accelerator::post('endpoint', [
'json' => ['key' => 'value'],
]);
Mail Transport
You can use MessageGears as a Laravel mail transport. Add the mailer to config/mail.php:
// config/mail.php
'mailers' => [
'messagegears' => [
'transport' => 'messagegears',
'campaign_id' => env('MESSAGEGEARS_CAMPAIGN_ID'),
],
],
Then send mail as usual:
Mail::mailer('messagegears')->to('user@example.com')->send(new WelcomeEmail());
TransactionalEmail Options
The TransactionalEmail notification supports a full set of fluent options:
TransactionalEmail::make()
->campaignId('CAMPAIGN_ID')
->campaignVersion('v2')
->context(['SubjectLine' => 'Hello'])
->category('marketing')
->correlationId('corr-123')
->latestSendTime('2030-01-01 12:00:00')
->notificationEmailAddress('alerts@example.com')
->fromAddress('noreply@example.com')
->fromName('My App')
->replyToAddress('support@example.com');
Testing
composer test # Run Pest tests
composer lint # Run Pint
composer analyse # Run PHPStan
composer rector # Run Rector (dry-run)
License
MIT
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v4.0.1 | ^8.3 | ^11.0| | ||
| v4.0.0 | ^8.3 | ^11.0| | ||
| v1.0.0 | ^8.1 | ^11.0 | ||
| v0.17.5 | ^8.1 | ^10.0 | ||
| v0.17.4 | ^8.1 | ^10.0 | ||
| v0.17.3 | ^8.1 | ^10.0 | ||
| v0.17.2 | ^8.1 | ^10.0 | ||
| v0.17.1 | ^8.1 | ^10.0 | ||
| v0.17.0 | ^8.1 | ^10.0 | ||
| v0.16.1 | ^8.0 | ^9.0 | ||
| v0.16.0 | ^8.0 | ^9.0 | ||
| v0.15.0 | ^8.0 | ^9.0 | ||
| v0.14.0 | ^8.0 | ^9.0 | ||
| v0.13.1 | ^8.0 | ^9.0 | ||
| v0.13.0 | ^8.0 | ^9.0 | ||
| v0.12.0 | ^7.0 | ^7.0| | ||
| v0.11.0 | ^7.0 | ^7.0 | ||
| v0.10.7 | ^7.0 | ^7.0 | ||
| v0.10.6 | ^7.0 | ^7.0 | ||
| v0.10.5 | ^7.0 | ^7.0 | ||
| v0.10.4 | ^7.0 | ^7.0 | ||
| v0.10.3 | ^7.0 | ^7.0 | ||
| v0.10.2 | ^7.0 | ^7.0 | ||
| v0.10.1 | ^7.0 | ^7.0 | ||
| v0.10.0 | ^7.0 | ^7.0 | ||
| v0.9.3 | ^7.0 | ^7.0 | ||
| v0.9.2 | ^7.0 | ^7.0 | ||
| v0.9.1 | ^7.0 | ^7.0 | ||
| v0.9.0 | ^7.0 | ^7.0 |