elasticemail/elasticemail-php
PHP client for Elastic Email’s REST API. Authenticate with your API key and manage campaigns and other resources via GET/POST/PUT/DELETE. Supports PHP 7.4+ (incl. 8.0) and uses Guzzle with configurable timeouts and connection limits.
GuzzleHttp) is already a dependency, reducing friction.CampaignsApi, ContactsApi) map cleanly to Laravel’s service layer, enabling encapsulation of ElasticEmail logic in dedicated services.EventsApi and StatisticsApi endpoints support real-time tracking, which can integrate with Laravel’s event system (e.g., queue:listen for async processing of email events).Http facade or GuzzleHttp\Client instances..env system can securely store the X-ElasticEmail-ApiKey, with dynamic binding via config/services.php.Campaign, Contact) for local persistence or caching.Laravel\Queue\Batch).updateCampaign) may need Laravel-level idempotency keys to handle retries safely.App\Exceptions\Handler should normalize these into consistent HTTP responses.sendBulkEmails) should leverage Laravel’s queues to avoid blocking requests.ELASTIC_EMAIL_API_KEY_STAGING)?Contact) sync bidirectionally with ElasticEmail’s API, or is it a read-only cache?Log channel or Prometheus)?Http::fake() or VCR recordings)?AppServiceProvider:
$this->app->singleton(ElasticEmail\Api\CampaignsApi::class, function ($app) {
$config = ElasticEmail\Configuration::getDefaultConfiguration()
->setApiKey('X-ElasticEmail-ApiKey', config('services.elasticemail.key'));
return new ElasticEmail\Api\CampaignsApi(new GuzzleHttp\Client(), $config);
});
ElasticEmail) to abstract API calls:
use Illuminate\Support\Facades\Facade;
class ElasticEmail extends Facade { protected static function getFacadeAccessor() { return 'elasticemail'; } }
SendBulkEmailsJob) for async operations, with middleware to enforce rate limits.shouldQueue() and onQueue() to route jobs to dedicated workers.EmailSent, CampaignPaused) for downstream services (e.g., analytics, notifications).sendTransactionalEmails) via a Laravel command or controller.CampaignService, ContactService) to encapsulate API logic.Mockery for API responses.email.bounced).^7.0 to align with Laravel’s dependencies.contacts or campaigns.elasticemail/elasticemail-php to composer.json and publish config (php artisan vendor:publish)..env and config/services.php.CampaignsApi, EmailsApi).Http::fake() to mock API responses.elasticemail/elasticemail-php for breaking changes (e.g., API deprecations).composer.json conflict rules to enforce version constraints.rotateApiKey command to update keys in .env and revoke old ones in ElasticEmail’s dashboard.tap method).CampaignService::send()) for other teams.Spatie\CircuitBreaker) for ElasticEmail’s API.loadCampaigns) using Laravel’s cache driver.campaign:{id}) for invalidation.| Failure Scenario | Mitigation Strategy |
|---|---|
| API Rate Limit Exceeded | Implement exponential backoff in Laravel’s HTTP client. |
| API Timeout (600s) | Use Laravel’s queue retries with jitter. |
| Authentication Failure | Fallback to a secondary API key or local queue storage. |
| Data Desync (Local vs. ElasticEmail) | Implement reconciliation jobs (e.g., SyncContactsJob) with conflict resolution. |
| ElasticEmail Outage | Queue emails locally and retry on recovery (e.g., using database queue driver). |
How can I help you explore Laravel packages today?