7.4. RCPT TO

The RCPT TO context allows verification of RCPT TO recipients.

7.4.1. Pre-defined variables

These are the read-only pre-defined variables available for RCPT TO command.

Variable Type Example Description
$messageid string “18c190a3-93f-47d7-bd...” ID of the message
$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
$senderhelo string “mail.example.com” HELO message of sender
$tlsstarted boolean false Whether or not the SMTP session is using TLS
$tlsprotocol string “TLSv1.2” Negotiated TLS version
$tlscipher string “DHE-RSA-AES256...” Negotiated TLS cipher
$tlskeysize number 256 Negotiated TLS key size
$saslusername string “mailuser” SASL username
$saslauthed boolean true Whether or not the SMTP session is authenticated (SASL)
$senderdomain string “example.org” Domain part of sender’s address (envelope)
$sender string “test@example.org” E-mail address of sender (envelope)
$senderparams array [“SIZE” => “2048”, ... ] Sender parameters to the envelope address
$recipientdomain string “example.com” Domain part of recipient’s address (envelope)
$recipient string “test@example.com” E-mail address of recipient (envelope)
$recipientparams array [“NOTIFY” => “NEVER”, .. ] Recipient parameters to the envelope address
$recipientdomains array [“example.com”, ...] List of all domain part of all recipient addresses (envelope)
$recipients array [“test@example.com”, ...] List of all recipient addresses (envelope), in order of scanning
$transportid string “mailtransport:1” ID of the transport profile to be used

These are the writable pre-defined variables available.

Variable Type Description
$context any Connection-bound variable

7.4.2. Functions

rcptto.Accept()

Accept the RCPT TO command (recipient).

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

Reject the RCPT TO command (recipient) with a permanent (554) error.

Parameters:
  • reason (string) – the reject message
  • options (array) – an options array
Returns:

doesn’t return, script is terminated

The following options are available in the options array.

  • disconnect (boolean) disconnect the client. The default is false.
rcptto.Defer([reason[, options]])

Defer the RCPT TO command (recipient) with a temporary (450) error.

Parameters:
  • reason (string) – the defer message
  • options (array) – an options array
Returns:

doesn’t return, script is terminated

The following options are available in the options array.

  • disconnect (boolean) disconnect the client. The default is false.
rcptto.SetSender(sender)

Change the sender of the message.

Parameters:sender (string) – an e-mail address
Returns:sender if successful
Return type:string or none
Updates:$sender and $senderdomain

Warning

This function changes the sender for all recipients. To change sender per recipient use SetSender() in the Pre-delivery context.

rcptto.SetRecipient(recipient)

Changes the recipient.

Parameters:recipient (string) – an e-mail address
Returns:recipient if successful
Return type:string or none
Updates:$recipient and $recipientdomain
rcptto.GetMailQueueMetric(options)

Return metric information about the mail queue, it can be used to enforce quotas.

Parameters:options (array) – options array

The following options are available in the options array.

  • metric (string) Metric to be returned; count or bytes. The default is count.
  • filter (array) Any of the available filters, see below. The default is no filters.

The following filters are available in the filters array.

Type Example
senderip $senderip
saslusername $saslusername
sender $sender
senderdomain $senderdomain
recipient $recipient
recipientdomain $recipientdomain
transportid $transportid
retry 1
$queuesize = GetMailQueueMetric(
        [
                "metric" => "bytes",
                "filter" => [
                        "senderdomain" => ["example.com" , "example.net"],
                        "transportid" => "mailtransport:2"
                ]
        ]
) / 1024 / 1024;
if ($queuesize > 500) {
        Defer("Current queue for mailtransport:2 exceeds 500 MiB");
}

Note

If multiple filters of the same type are given using array notation, any of them may match.

7.4.3. On script error

On script error Defer() is called.

7.4.4. On implicit termination

If not explicitly terminated then Reject() is called (if not $error is set, then Defer() is called instead).