interserver/mailbaby-client-php
Composer 安装命令:
composer require interserver/mailbaby-client-php
包简介
**Send emails fast and with confidence through our easy to use [REST](https://en.wikipedia.org/wiki/Representational_state_transfer) API interface.** # Overview This is the API interface to the [Mail Baby](https://mail.baby/) Mail services provided by [InterServer](https://www.interserver.net). To
README 文档
README
Send emails fast and with confidence through our easy to use REST API interface.
Overview
This is the API interface to the Mail Baby Mail services provided by InterServer. To use this service you must have an account with us at my.interserver.net.
Mail Orders
Every sending account in MailBaby is backed by a Mail Order — a provisioned sending credential with a numeric id and a corresponding SMTP username (mb<id>). Most calls accept an optional id parameter; when omitted the API automatically selects the first active order on your account. Use GET /mail to list all orders, and GET /mail/{id} to inspect a single order including its current SMTP password.
Sending Email
Three sending methods are available depending on your use-case:
| Endpoint | Best for | |----------|----------| | POST /mail/send | Simple single-recipient messages | | POST /mail/advsend | Multiple recipients, CC/BCC, attachments, named contacts | | POST /mail/rawsend | Pre-built RFC 822 messages (e.g. DKIM-signed payloads) |
After a successful send each endpoint returns a GenericResponse whose text field contains the transaction ID assigned by the relay. This ID can later be matched against entries in GET /mail/log via the mailid query parameter.
Filtering & Logs
GET /mail/log provides paginated access to every message accepted by the relay for your account. Combine any of the query parameters to narrow results — e.g. from, to, subject, messageId, origin, mx, startDate/endDate, and delivered.
Blocking
Two independent mechanisms exist for suppressing unwanted email:
- Block lists (
GET /mail/blocks,POST /mail/blocks/delete) — addresses flagged by the system spam filters (LOCAL_BL_RCPT / MBTRAP rules in rspamd, and suspicious subjects). - Deny rules (
GET /mail/rules,POST /mail/rules,DELETE /mail/rules/{ruleId}) — custom rules you configure to reject specific senders, domains, destination addresses, or subject-line prefixes before a message is even attempted.
Authentication
In order to use most of the API calls you must pass credentials from the my.interserver.net site.
We support several different authentication methods but the preferred method is to use the API Key which you can get from the Account Security page.
Pass your key in the X-API-KEY HTTP request header for every protected call.
For more information, please visit https://www.mail.baby/contact/.
Installation & Usage
Requirements
PHP 8.1 and later.
Composer
To install the bindings via Composer, add the following to composer.json:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/interserver/mailbaby-client-php.git"
}
],
"require": {
"interserver/mailbaby-client-php": "*@dev"
}
}
Then run composer install
Manual Installation
Download the files and include autoload.php:
<?php require_once('/path/to/MailBaby/vendor/autoload.php');
Getting Started
Please follow the installation procedure and then run the following:
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure API key authorization: apiKeyAuth $config = Interserver\Mailbaby\Configuration::getDefaultConfiguration()->setApiKey('X-API-KEY', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = Interserver\Mailbaby\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-KEY', 'Bearer'); $apiInstance = new Interserver\Mailbaby\Api\BlockingApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $type = 'type_example'; // string | The matching strategy for this rule. `email` blocks an exact sender address, `domain` blocks all senders at a domain, `destination` blocks an exact recipient address, and `startswith` blocks any sender whose local-part begins with the given prefix. $data = 'data_example'; // string | The value to match against, interpreted according to `type`: a full email address for `email`/`destination`, a domain name for `domain`, or an alphanumeric prefix string for `startswith`. $user = 'user_example'; // string | Optional SMTP username of the mail order to associate this rule with (e.g. `mb20682`). If omitted the first active order is used. Valid usernames are the `username` values returned by `GET /mail`. try { $result = $apiInstance->addRule($type, $data, $user); print_r($result); } catch (Exception $e) { echo 'Exception when calling BlockingApi->addRule: ', $e->getMessage(), PHP_EOL; }
API Endpoints
All URIs are relative to https://api.mailbaby.net
| Class | Method | HTTP request | Description |
|---|---|---|---|
| BlockingApi | addRule | POST /mail/rules | Creates a new email deny rule |
| BlockingApi | deleteRule | DELETE /mail/rules/{ruleId} | Removes a deny mail rule |
| BlockingApi | delistBlock | POST /mail/blocks/delete | Removes an email address from the block lists |
| BlockingApi | getMailBlocks | GET /mail/blocks | Displays a list of blocked email addresses |
| BlockingApi | getRules | GET /mail/rules | Displays a listing of deny email rules |
| HistoryApi | getStats | GET /mail/stats | Account usage statistics |
| HistoryApi | viewMailLog | GET /mail/log | Displays the mail log |
| SendingApi | rawMail | POST /mail/rawsend | Sends a raw RFC 822 email |
| SendingApi | sendAdvMail | POST /mail/advsend | Sends an Email with Advanced Options |
| SendingApi | sendMail | POST /mail/send | Sends an Email |
| ServicesApi | getMailOrderById | GET /mail/{id} | Displays details for a single mail order |
| ServicesApi | getMailOrders | GET /mail | Displays a list of mail service orders |
| StatusApi | pingServer | GET /ping | Checks if the server is running |
Models
- DateOrTimestamp
- DenyRuleNew
- DenyRuleRecord
- EmailAddressName
- EmailAddressNames
- EmailAddressParam
- EmailAddressTypes
- EmailAddressesTypes
- ErrorMessage
- GenericResponse
- MailAttachment
- MailBlockClickHouse
- MailBlockRspamd
- MailBlocks
- MailLog
- MailLogEntry
- MailOrder
- MailOrderDetail
- MailStatsType
- MailStatsVolume
- SendMail
- SendMailAdv
- SendMailRaw
- SendMailTo
Authorization
Authentication schemes defined for the API:
apiKeyAuth
- Type: API key
- API key parameter name: X-API-KEY
- Location: HTTP header
Tests
To run the tests, use:
composer install vendor/bin/phpunit
Author
About this package
This PHP package is automatically generated by the OpenAPI Generator project:
- API version:
1.4.0- Package version:
1.0.0 - Generator version:
7.21.0
- Package version:
- Build package:
org.openapitools.codegen.languages.PhpClientCodegen
interserver/mailbaby-client-php 适用场景与选型建议
interserver/mailbaby-client-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 206 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 05 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「sdk」 「swagger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 interserver/mailbaby-client-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 interserver/mailbaby-client-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 interserver/mailbaby-client-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Alfabank REST API integration
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
A lightweight plain-PHP framework for database-backed CRUD APIs.
bughq error tracking - PHP SDK
ABsurge PHP SDK for feature flags and A/B testing
统计信息
- 总下载量: 206
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2021-05-03