Haraka Integration¶
This guide covers integrating tobira with Haraka using the Node.js plugin.
Prerequisites¶
- Haraka mail server
- Node.js >= 18
- tobira API server running and accessible
Installation¶
-
Install the tobira npm package in your Haraka installation:
-
Copy the plugin file:
Or copy from the tobira repository:
-
Create the configuration file
config/tobira.ini: -
Enable the plugin by adding
tobiratoconfig/plugins: -
Restart Haraka:
Configuration Options¶
| Option | Default | Description |
|---|---|---|
url |
http://127.0.0.1:8000 |
tobira API server base URL |
timeout |
5000 |
HTTP request timeout in milliseconds |
threshold |
0.5 |
Spam score threshold for rejection |
reject_spam |
true |
Reject emails above threshold |
send_headers |
false |
Send email headers for analysis |
How It Works¶
The plugin hooks into Haraka's data_post event:
- Collects the email body text from the transaction
- Optionally extracts email headers (SPF, DKIM, DMARC, From, Reply-To, Received, Content-Type)
- Sends a POST request to the tobira
/predictendpoint - Adds results to the transaction using
transaction.results.add() - If
reject_spamis enabled and the score exceeds the threshold, the message is rejected with a 550 response
Transaction Results¶
The plugin adds results to transaction.results under the tobira namespace:
{
pass: "score=0.12", // if classified as ham
fail: "score=0.95", // if classified as spam
score: 0.95,
label: "spam"
}
Other plugins can access these results:
Header Analysis¶
Set send_headers = true to include email authentication results in the classification request. The plugin extracts:
- SPF result from
Received-SPFheader - DKIM result from
DKIM-Signatureheader - DMARC result from
Authentication-Resultsheader - From, Reply-To, Received, and Content-Type headers
Verification¶
Check the Haraka log for tobira plugin activity:
Troubleshooting¶
Plugin not loading: Ensure tobira is listed in config/plugins and the tobira npm package is installed.
Connection refused: Verify the API server URL in config/tobira.ini and check that the server is running.
Timeout errors: Increase the timeout value in config/tobira.ini.