Skip to content

Latest commit

 

History

History
322 lines (218 loc) · 14.2 KB

File metadata and controls

322 lines (218 loc) · 14.2 KB

Interserver\Mailbaby\BlockingApi

Manage block lists and custom deny rules to prevent unwanted outbound email.

All URIs are relative to https://api.mailbaby.net, except if the operation defines another base path.

Method HTTP request Description
addRule() POST /mail/rules Creates a new email deny rule
deleteRule() DELETE /mail/rules/{ruleId} Removes a deny mail rule
delistBlock() POST /mail/blocks/delete Removes an email address from the block lists
getMailBlocks() GET /mail/blocks Displays a list of blocked email addresses
getRules() GET /mail/rules Displays a listing of deny email rules

addRule()

addRule($type, $data, $user): \Interserver\Mailbaby\Model\GenericResponse

Creates a new email deny rule

Adds a deny rule to block specific senders, domains, destinations, or sender prefixes from being relayed through your mail account. The type field selects the matching strategy: - email — exact match against the SMTP envelope MAIL FROM address. - domain — matches any sender address at the specified domain. - destination — exact match against the SMTP envelope RCPT TO address. - startswith — matches any sender address whose local-part (the portion before the @) starts with the given string. Only alphanumeric characters and +, _, ., - are permitted in the prefix. If username is provided it must be the SMTP username of one of your active mail orders (e.g. mb20682). If omitted the rule is associated with your first active order. On success the response text field contains the newly created rule's id, which can later be passed to DELETE /mail/rules/{ruleId} to remove it.

Example

<?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;
}

Parameters

Name Type Description Notes
type 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 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 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`. [optional]

Return type

\Interserver\Mailbaby\Model\GenericResponse

Authorization

apiKeyAuth

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded, application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

deleteRule()

deleteRule($ruleId): \Interserver\Mailbaby\Model\GenericResponse

Removes a deny mail rule

Permanently removes a single deny rule identified by its numeric ruleId. The ruleId is the id field returned by GET /mail/rules or the text field from a successful POST /mail/rules response. Only rules belonging to your own active mail account(s) can be deleted — the server will reject attempts to delete rules that belong to a different account.

Example

<?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
);
$ruleId = 34; // int | The numeric ID of the deny rule to delete.  Obtain this from the `id` field in `GET /mail/rules` or the `text` field of a `POST /mail/rules` response.

try {
    $result = $apiInstance->deleteRule($ruleId);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling BlockingApi->deleteRule: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
ruleId int The numeric ID of the deny rule to delete. Obtain this from the `id` field in `GET /mail/rules` or the `text` field of a `POST /mail/rules` response.

Return type

\Interserver\Mailbaby\Model\GenericResponse

Authorization

apiKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

delistBlock()

delistBlock($emailAddressParam): \Interserver\Mailbaby\Model\GenericResponse

Removes an email address from the block lists

Delists an email address from all three block list stores: 1. The rspamd spam-filter database (fromemail / envelope sender records). 2. The MailChannels integration block table. 3. The MailBaby internal block table. Use GET /mail/blocks to discover which addresses are currently blocked. The from field in any returned block entry is a valid input for this call. Note: Delisting an address removes it from the block tracking databases but does not prevent the spam filter from re-blocking it if future messages continue to trigger filter rules.

Example

<?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
);
$emailAddressParam = {"email":"client@domain.com"}; // \Interserver\Mailbaby\Model\EmailAddressParam

try {
    $result = $apiInstance->delistBlock($emailAddressParam);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling BlockingApi->delistBlock: ', $e->getMessage(), PHP_EOL;
}

Parameters

Name Type Description Notes
emailAddressParam \Interserver\Mailbaby\Model\EmailAddressParam

Return type

\Interserver\Mailbaby\Model\GenericResponse

Authorization

apiKeyAuth

HTTP request headers

  • Content-Type: application/json, application/x-www-form-urlencoded
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

getMailBlocks()

getMailBlocks(): \Interserver\Mailbaby\Model\MailBlocks

Displays a list of blocked email addresses

Returns addresses and messages that have been flagged by the spam filtering system for your mail account(s). Three categories are returned: - local — messages flagged by the LOCAL_BL_RCPT rspamd rule. These are messages sent to recipients on your account's local block list. - mbtrap — messages flagged by the MBTRAP rspamd rule. These are messages that triggered MailBaby's internal trap / honeypot detection. - subject — senders whose recent messages contain spam-indicative subjects (strings containing @, smtp, socks4, or socks5) with high repetition (more than 4 identical subjects from the same sender in the last 3 days). The local and mbtrap results cover the last 5 days. The subject results cover the last 3 days. A sender address returned in any of these lists can be delisted using POST /mail/blocks/delete with the email field set to that address.

Example

<?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
);

try {
    $result = $apiInstance->getMailBlocks();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling BlockingApi->getMailBlocks: ', $e->getMessage(), PHP_EOL;
}

Parameters

This endpoint does not need any parameter.

Return type

\Interserver\Mailbaby\Model\MailBlocks

Authorization

apiKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

getRules()

getRules(): \Interserver\Mailbaby\Model\DenyRuleRecord[]

Displays a listing of deny email rules

Returns all deny rules you have configured for your active mail account(s). Deny rules are evaluated before a message is transmitted and cause it to be rejected immediately when it matches. Four rule types are supported: | type | data format | Effect | |--------|---------------|--------| | email | user@domain.com | Rejects any message from this exact sender address | | domain | domain.com | Rejects any message from any address at this domain | | destination | user@domain.com | Rejects any message addressed to this recipient | | startswith | prefix | Rejects any message whose sender address begins with this string (alphanumeric, +, _, ., - only) | Use POST /mail/rules to add new rules and DELETE /mail/rules/{ruleId} to remove them. The id field in each returned record is the value needed for the delete call.

Example

<?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
);

try {
    $result = $apiInstance->getRules();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling BlockingApi->getRules: ', $e->getMessage(), PHP_EOL;
}

Parameters

This endpoint does not need any parameter.

Return type

\Interserver\Mailbaby\Model\DenyRuleRecord[]

Authorization

apiKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]