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 asmailto:user@example.com - A single URL (
https://example.com/unsub) - Both as an array (
['user@example.com', 'https://example.com/unsub'])
- A single email (
- 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
| Method | Description |
|---|---|
| setMessageType | Set message type: transaction or bulk |
| setFrom | Set sender email and name |
| addTo | Add transactional recipient (name optional) |
| addRecipient | Add bulk recipient (name, email) |
| setSubject | Set subject |
| setMessage | Set message body (HTML or text) |
| addAttachment | Add base64-encoded attachment |
| setUnsubscribe | Set unsubscribe (email, URL, or both) |
| setListId | Set List-ID (bulk only) |
| setBounceAddr | Set bounce address (optional) |
| addCc | Add CC (transactional only) |
| send | Send the composed message |
| lookupStatus | Get status of a sent message |
| getDkim | Retrieve 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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bulkto/bulkto-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DKIM Signer for Laminas Mail
Very light weight PHP API for email sending and digital signing covering most important parts of RFC-4021 & RFC-6376 specs
DKIM Signer for Zend Mail
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-27