7.1. CONNECT

The CONNECT context is executed before the SMTP banner is sent.

7.1.1. Pre-defined variables

These are the read-only pre-defined variables available for each connection that is established.

7.1.1.1. Connection

These are the writable pre-defined variables available.

Variable Type Description
$context any Connection-bound variable

7.1.1.2. Transaction

Variable Type Example Description
$messageid string “18c190a3-93f-47d7-bd...” ID of the message

7.1.1.3. Arguments

Variable Type Example Description
$senderip string “192.168.1.11” IP address of the connected client
$senderport number 41666 TCP port of connected client
$serverip string “10.0.0.1” IP address of the mailserver
$serverport number 25 TCP port of the mailserver
$serverid string “mailserver:1” ID of the mailserver profile

7.1.2. Functions

connect.Accept()

Allow SMTP connection to be established.

Returns:doesn’t return, script is terminated
connect.Reject([reason[, options]])

Reject 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]])

Defer 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.
connect.SetSenderIP(senderip)

Change the senderip for the current connection.

Parameters:senderip (string) – an IP address
Returns:senderip if successful
Return type:string or none
Updates:$senderip

Note

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

$x = unpack("N*", inet_pton($senderip));
if (count($x) == 4 and $x[0:3] == [6619035, 0, 0]) // 64:ff9b::[IPv4]
        SetSenderIP(inet_ntop(pack("N", $x[3])));

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.