Connection Object
May 13, 2026 · View on GitHub
For each connection to Haraka there is one connection object. It is the first argument passed to almost every plugin hook and is the primary context object plugins use to inspect and act on the SMTP session.
Properties
connection.uuid
A unique UUID for this connection. Used as the connection identifier in logs and inherited by transaction.uuid.
connection.remote
Information about the host connecting to Haraka.
ip— remote IP addressport— remote TCP porthost— reverse DNS of the remote IP (populated by theconnect.rdns_access/connecthooks)info— free-form descriptor (e.g. populated by FCrDNS)closed—trueonce the remote end has dropped the connectionis_private—trueif the remote IP is in a private range (RFC 1918, loopback, link-local, etc.)is_local—trueif the remote IP is localhost / loopback
connection.local
Information about the Haraka server endpoint handling this connection.
ip— the IP of the Haraka server, as reported by the OSport— the port number handling the connectionhost— the primary host name of the Haraka serverinfo—Haraka(with/<version>appended whenheaders.show_versionis enabled inconnection.ini)
connection.hello
The greeting given by the client.
verb—EHLOorHELO, whichever the client usedhost— the hostname argument
connection.tls
State of the TLS layer on this connection.
enabled—trueonce STARTTLS has been negotiated (or the listener issmtps)advertised—trueif Haraka advertised STARTTLS in the EHLO responseverified—trueif the peer certificate validated against the configured CAscipher— the negotiated cipher object (name,version, …)verifyError— the verification error, if anypeerCertificate— the parsed peer certificate (when client certs are used)
connection.proxy
Proxy-protocol state, set when the connection arrived via HAProxy (see HAProxy.md).
allowed—trueif the remote IP is in thehaproxy.hostsallow-listip— the proxy server's IP (the real client IP appears inconnection.remote.iponce PROXY is parsed)type— currentlynullor'haproxy'
connection.notes
A plain object that persists for the lifetime of the connection. Use it to share state between plugin hooks. For structured per-test results prefer connection.results. See also haraka-notes.
connection.results
Structured store for plugin results. See haraka-results.
connection.transaction
The current Transaction object. Valid between MAIL FROM and the end of queue / RSET (or until MAIL FROM is rejected). See Transaction.md.
connection.relaying
Boolean. true if this connection is allowed to relay (i.e. deliver mail outbound). Normally set by an auth plugin or an IP allow-list. Reading or writing this property transparently routes through the current transaction when one exists, so the flag survives across multiple messages in a single connection only when set on the connection.
connection.capabilities
Array of ESMTP capabilities advertised in the EHLO response (e.g. ['PIPELINING', '8BITMIME', 'SIZE 0', 'STARTTLS', 'AUTH PLAIN LOGIN']). Plugins may push additional capability strings during the capabilities hook.
connection.esmtp
true if the client used EHLO (as opposed to HELO).
connection.pipelining
true once Haraka has advertised, and the client has used, SMTP pipelining.
connection.early_talker
true if the client sent data before Haraka issued its banner — a
common spam-bot signal.
connection.tran_count
Number of transactions completed on this connection.
connection.rcpt_count / connection.msg_count
Per-disposition counters (accept, tempfail, reject) tracking
recipients and full messages on this connection.
connection.start_time
Connection start time, in epoch milliseconds (Date.now()).
connection.last_response
The last SMTP response line Haraka sent to the client.
connection.last_reject
The text of the last rejection issued to this client (used by
max_unrecognized_commands and similar throttling plugins).
connection.errors
Count of protocol errors on this connection.
connection.current_line
Low-level. The current line as sent by the remote end, verbatim. Useful for botnet fingerprinting.
connection.state
The connection's protocol state — one of the values in haraka-constants's connection.state table (PAUSE, CMD, LOOP, DATA, DISCONNECTING, DISCONNECTED).
Methods
connection.respond(code, msg, cb)
Send an SMTP response to the client. code is the numeric SMTP code, msg is the human-readable text (a string or an array of strings for a multi-line response). The callback fires when the response has been written.
connection.disconnect()
Close the connection after running the disconnect hook.
connection.reset_transaction(cb)
Tear down the current transaction (equivalent to RSET) and invoke cb when complete.
connection.set(path, value)
Assign a nested property safely, e.g. connection.set('remote.host', 'mx.example.com'). Setting remote.ip
automatically recomputes remote.is_private / remote.is_local.
connection.get(path)
Read a nested property, returning undefined if any segment is missing.
connection.loginfo / lognotice / logwarn / logerror / logdebug / logcrit / logalert / logemerg / logprotocol / logdata
Log at the named level. Each takes either (msg) or (plugin, msg, data).
See Logging.md.