bulkto/bulkto-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

bulkto/bulkto-client

Composer 安装命令:

composer require bulkto/bulkto-client

包简介

BulkTo transactional & bulk mail PHP client (end-user API only).

README 文档

README

BulkTo PHP Client is a modern, Composer-installable library for integrating your PHP applications with the BulkTo transactional & bulk email API.

  • Send transactional (one-to-one) or bulk (multi-recipient) mail
  • Get delivery status
  • Retrieve user DKIM keys
  • Handles attachments, unsubscribe, custom bounce, and more
  • Robust input validation and exception handling
  • Designed for simple integration into any PHP project

Installation

composer require bulkto/bulkto-client

Requires PHP 8.0+ and GuzzleHttp.

Usage

Basic Initialization

use BulkTo\Client;

$jwt = 'your-jwt-token-here';
$bulkto = new Client($jwt);
// Optionally: $bulkto = new Client($jwt, 'https://api.bulkto.net');

Sending a Transactional Email

$bulkto->setMessageType('transaction')
    ->setFrom('sender@example.com', 'Sender Name')
    ->addTo('recipient@example.com') // or ->addTo('Recipient Name', 'recipient@example.com')
    ->setSubject('Hello')
    ->setMessage('<p>Welcome to BulkTo!</p>')
    ->addAttachment('welcome.pdf', 'application/pdf', $base64data)
    ->setUnsubscribe(['recipient@example.com', 'https://example.com/unsub'])
    ->setBounceAddr('bounces@example.com');

$response = $bulkto->send();
// $response contains API response data (e.g. status, message ID)

You should store the message-id provided back to you from the send call for looking up delivery status later

Sending a Bulk Email

$bulkto->setMessageType('bulk')
    ->setFrom('no-reply@example.com', 'Acme Team')
    ->addRecipient('Alice', 'alice@example.com')
    ->addRecipient('Bob', 'bob@example.com')
    ->setSubject('Monthly Update')
    ->setMessage('<h1>Hi!</h1><p>Our newsletter...</p>')
    ->setListId('list-42')
    ->setUnsubscribe(['unsubscribe@example.com', 'https://example.com/unsub'])
    ->addAttachment('promo.jpg', 'image/jpeg', $base64data)
    ->setBounceAddr('bounce@example.com');

$response = $bulkto->send();

Status Lookup

$status = $bulkto->lookupStatus('message-id-xyz'); // returns delivery status info
$statusByRecipient = $bulkto->lookupStatus('message-id-xyz', 'bob@example.com');

DKIM Lookup

$dkim = $bulkto->getDkim('user-uuid'); // returns DKIM public key info

Unsubscribe Handling

  • You must provide a List-Unsubscribe value for bulk mail.
  • Acceptable:

    • A single email (user@example.com) — will be sent as mailto:user@example.com
    • A single URL (https://example.com/unsub)
    • Both as an array (['user@example.com', 'https://example.com/unsub'])
  • Not allowed: two emails, or two URLs.

Example:

// All are valid:
$bulkto->setUnsubscribe('user@example.com');
$bulkto->setUnsubscribe('https://example.com/unsub');
$bulkto->setUnsubscribe(['user@example.com', 'https://example.com/unsub']);

Error Handling

All exceptions extend BulkTo\Exception\BulkToException. You can catch specific error types:

use BulkTo\Exception\BulkToValidationException;
use BulkTo\Exception\BulkToApiException;

try {
    $bulkto->setFrom('bad-email');
} catch (BulkToValidationException $e) {
    // Input error
}

try {
    $bulkto->send();
} catch (BulkToApiException $e) {
    // API/server error
} catch (BulkToValidationException $e) {
    // Input error (e.g. missing field)
} catch (BulkToException $e) {
    // All other errors
}

Testing

Unit tests provided (see tests/). Run with:

./vendor/bin/phpunit tests

API Methods

MethodDescription
setMessageTypeSet message type: transaction or bulk
setFromSet sender email and name
addToAdd transactional recipient (name optional)
addRecipientAdd bulk recipient (name, email)
setSubjectSet subject
setMessageSet message body (HTML or text)
addAttachmentAdd base64-encoded attachment
setUnsubscribeSet unsubscribe (email, URL, or both)
setListIdSet List-ID (bulk only)
setBounceAddrSet bounce address (optional)
addCcAdd CC (transactional only)
sendSend the composed message
lookupStatusGet status of a sent message
getDkimRetrieve user DKIM public key

Contributing

Pull requests, bug reports, and suggestions welcome! Please open issues or PRs via your Portal.

(https://git.bandabi.ca/bulkto/php-client.git).

License

MIT

BulkTo is a trademark of Aim 4 The Cloud Inc



bulkto/bulkto-client 适用场景与选型建议

bulkto/bulkto-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「email」 「composer」 「dkim」 「bulk mail」 「transactional mail」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 bulkto/bulkto-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 bulkto/bulkto-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 bulkto/bulkto-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-27