7.1. Connect

This script is executed before the SMTP banner is sent.

7.1.1. Variables

These are the pre-defined variables available.

Variable

Type

Read-only

Description

$arguments

array

yes

Context/hook arguments

$connection

array

yes

Connection/session bound

$transaction

array

yes

Transaction bound

$context

any

no

Connection bound user-defined (default none)

7.1.1.1. Arguments

Array item

Type

Example

Description

remoteip

string

“192.168.1.11”

IP address of the connected client

remoteport

number

41666

TCP port of connected client

remoteptr

string

“mail.example.org”

Reverse DNS (FCrDNS) for remoteip (not always available)

remoteuid

number

106

UNIX socket remote user id (not always available)

localip

string

“10.0.0.1”

IP address of the server

localport

number

25

TCP port of the server

serverid

string

“inbound”

ID of the server

proxyip

string

“192.168.1.1”

IP address of the proxy server (not always available)

7.1.1.2. Connection

Array item

Type

Example

Description

id

string

“18c190a3-93f-47d7-bd…”

ID of the connection

7.1.1.3. Transaction

Array item

Type

Example

Description

id

string

“18c190a3-93f-47d7-bd…”

ID of the transaction

7.1.2. Functions

connect.Accept([options])

Allow the connection to be established. Optionally change the remoteip and PTR of the accepted client connection, which is written back to the $connection variable.

Parameters

options (array) – an options array

Returns

doesn’t return, script is terminated

The following options are available in the options array.

  • remoteip (string) Change the IP address of the accepted client connection.

  • remoteptr (string) Set the reverse DNS pointer (PTR) for the IP address.

  • reason (string or array) The greeting banner response.

  • reply_codes (array) The array may contain code (number) and enhanced (array of three numbers). The default is pre-defined.

Note

The remoteptr option can be useful for eg. decoding IPv4 addresses embedded in an IPv6 address (RFC6052).

$x = unpack("N*", inet_pton($arguments["remoteip"]));
if (length($x) == 4 and $x[0:3] == [6619035, 0, 0]) // 64:ff9b::[IPv4]
        $ip = inet_ntop(pack("N", $x[3]));
connect.Reject([reason[, options]])

Close the connection with a permanent (521) error.

Parameters
  • reason (string or array) – reject message with reason

  • options (array) – an options array

Returns

doesn’t return, script is terminated

The following options are available in the options array.

  • reply_codes (array) The array may contain code (number) and enhanced (array of three numbers). The default is pre-defined.

connect.Defer([reason[, options]])

Close the connection with a temporary (421) error.

Parameters
  • reason (string or array) – defer message with reason

  • options (array) – an options array

Returns

doesn’t return, script is terminated

The following options are available in the options array.

  • reply_codes (array) The array may contain code (number) and enhanced (array of three numbers). The default is pre-defined.

7.1.3. On script error

On script error Defer() is called.

7.1.4. On implicit termination

If not explicitly terminated then Accept() is called.