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
Package info
github.com/interserver/mailbaby-client-php
pkg:composer/interserver/mailbaby-client-php
Requires
- php: >=5.5
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ~1.12
- phpunit/phpunit: ^4.8
- squizlabs/php_codesniffer: ~2.6
This package is auto-updated.
Last update: 2026-03-25 20:34:20 UTC
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 type of deny rule. $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
- 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