4. HTTP API

The message to classify should be sent in as a JSON object with a message property.

curl -X 'POST' \
    'http://127.0.0.1:8000/v1/bnac/batch' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{"message": "451 4.7.1 <[email protected]>: Recipient address rejected: Greylisting in effect, please come back later"}'

This request passes in a message and receives a result: {"class":"GRAYLISTING"}

4.1. Results

An object with a class property is returned, the classifications can be:

Classification

Suggested Action

Severity

Scope

BLOCK_LIST

Recipient MTA is blocking, with third-party

(e.g. Spamhaus,..) information

5

tenantid

BLOCKED

Recipient MTA is blocking,

no third-party information

3

tenantid,

grouping

DKIM

Fix DKIM

3

tenantid,

grouping

DMARC

Fix DMARC

3

tenantid,

grouping

DNS_PTR

Fix reverse DNS

3

tenantid,

grouping

DOMAIN_REPUTATION

Slow down from this sending domain

4

tenantid,

grouping

GRAYLISTING

Slow down to this recipient domain,

you are at risk of being blocked

3

tenantid,

grouping

IP_REPUTATION

Slow down from this sending IP

4

localip,

grouping

MESSAGE_CONTENT

Suspend campaign and review what is sent

3

jobid

MX_ERROR

Verify your DNS resolution of this recipient

domain

3

remotemx

RATE_LIMIT

Slow down to this recipient domain

3

grouping

RECIPIENT_ERROR

Slow down, possible poor list quality,

reduce frequency to this address

2

jobid,

grouping

RECIPIENT_NOT_FOUND

Remove the address

1

recipient address

SPF

Fix SPF

3

tenantid,

grouping

TEMPORARY_ERROR

Slow down sending to this recipient domain

1

tenantid,

grouping

TLS

Check your TLS negotiation with this

recipient domain

3

tenantid,

grouping

VIRUS

Suspend campaign and review what is sent

6

jobid

4.1.1. Severity

  • 6 = Most severe impact on sender reputation

  • 1 = Lowest impact on sender reputation

4.2. Example HSL script

This example script can be run from the terminal directly with hsh. It is equivalent to the curl example above, passing in a message and receiving a response.

$guru = "http://127.0.0.1:8000/v1/bnac/batch";
$options = ["headers" => ["Content-Type: application/json", "Accept: application/json"], "extended_result" => true];
$data = "451 4.7.1 <[email protected]>: Recipient address rejected: Greylisting in effect, please come back later";
$payload = json_encode(["message" => $data]);
$res = http($guru, $options, [], $payload);
if ($res["content"]) {
    $content = json_decode($res["content"]);
    $class = $content["class"];
    echo $class;
}

For best performance in calls from script hooks, use the http-background plugin instead of the foreground http function.