定制 sendbyte/sendbyte-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sendbyte/sendbyte-php

Composer 安装命令:

composer require sendbyte/sendbyte-php

包简介

SendByte PHP SDK: the email API for Africa. Laravel-friendly.

README 文档

README

The official PHP SDK for SendByte, the email API for Africa. Laravel friendly, requires only ext-curl and ext-json.

Install

composer require sendbyte/sendbyte-php

Requires PHP 8.0 or newer.

Quickstart

<?php

use SendByte\SendByte;

$sendbyte = new SendByte('sk_test_...');

$email = $sendbyte->sendEmail([
    'from' => 'PayLink <receipts@paylink.ng>',
    'to' => 'amaka@halo.ng',
    'subject' => 'Receipt for your payment',
    'html' => '<p>Thank you. Your payment was received.</p>',
]);

echo $email['id'];

Keys that start with sk_test_ run in the sandbox: every endpoint behaves the same, but nothing is actually delivered. Switch to an sk_live_ key to send for real.

Configuration

$sendbyte = new SendByte('sk_live_...', 'https://api.sendbyte.africa');

API

Emails

$sendbyte->sendEmail(['from' => ..., 'to' => ..., 'subject' => ..., 'html' => ...]);
$sendbyte->getEmail('em_123');
$sendbyte->listEmails(['limit' => 20, 'status' => 'delivered']);

to, cc, bcc, and reply_to accept a single address or an array. Pass idempotency_key to make retries safe, scheduled_at for future sends, and template_id with variables to render a server side template.

Domains

$domain = $sendbyte->createDomain('paylink.ng');
// $domain['dns_records'] lists the SPF, DKIM, and DMARC records to publish
$sendbyte->listDomains();
$sendbyte->getDomain($domain['id']);
$sendbyte->verifyDomain($domain['id']);

Webhooks

$endpoint = $sendbyte->createWebhook(
    'https://example.com/hooks/sendbyte',
    ['email.delivered', 'email.bounced']
);
// $endpoint['secret'] is shown once, store it now
$sendbyte->listWebhooks();
$sendbyte->disableWebhook($endpoint['id']);
$sendbyte->replayWebhookDelivery('evt_123');

Verifying webhook signatures

Every webhook request carries a sendbyte-signature header. Verify it against the raw request body before trusting the payload.

$raw = file_get_contents('php://input');
$valid = SendByte::verifyWebhookSignature(
    $_ENV['SENDBYTE_WEBHOOK_SECRET'],
    $_SERVER['HTTP_SENDBYTE_SIGNATURE'] ?? null,
    $raw
);
if (!$valid) {
    http_response_code(401);
    exit;
}
// handle the event

The check rejects missing, malformed, tampered, and stale signatures (default tolerance is 300 seconds).

Errors

Failed requests throw a SendByteException carrying the API error shape.

use SendByte\SendByteException;

try {
    $sendbyte->sendEmail([...]);
} catch (SendByteException $e) {
    echo $e->errorCode . ' ' . $e->status . ' ' . $e->getMessage();
    echo $e->docsUrl;
}

Links

License

MIT

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固