mailgatewayid / php
Official zero-dependency PHP client for MailGateway.id Email API
v0.2.0
2026-11-11 14:09 UTC
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
SDK resmi MailGateway.id untuk PHP 8.1+ (ext-curl, ext-json). Tanpa dependency.
composer require mailgatewayid/php
use MailGateway\MailGateway; use MailGateway\MailGatewayException; $mg = new MailGateway(getenv('MAILGATEWAY_API_KEY')); try { $mg->send([ 'from' => 'no-reply@domainanda.id', 'to' => 'user@example.com', 'subject' => 'Invoice INV-1001', 'html' => '<p>Terima kasih!</p>', ], idempotencyKey: 'invoice-INV-1001'); // opsional, retry aman 24 jam } catch (MailGatewayException $e) { error_log($e->getMessage()); } $mg->verify('user@gmail.com'); MailGateway::verifyWebhookSignature($rawBody, $_SERVER['HTTP_X_MAILGATEWAY_SIGNATURE'] ?? null, getenv('MAILGATEWAY_WEBHOOK_SECRET'));
Idempotency-Key: request ulang dengan key dan payload sama mengembalikan respons awal tanpa mengirim ulang atau memotong kuota.