4.12.1.15 Polling Functions

We have described the base notions about sender address verification (or polling, for short) in Checking Sender Address. Here we will describe the functions mailfromd offers for this purpose.

Built-in Function: number _pollhost   (string ip, string email, string domain,   string mailfrom)

Poll SMTP host ip for email address email, using domain as EHLO domain and mailfrom as MAIL FROM. Returns 0 or 1 depending on the result of the test. In contrast to the strictpoll function, this function does not use cache database and does not fall back to polling MX servers if the main poll tempfails. The function can throw one of the following exceptions: e_failure, e_temp_failure.

Built-in Function: number _pollmx   (string ip, string email, string domain,   string mailfrom)

Poll MXs of the domain for email address email, using domain as EHLO domain and mailfrom as MAIL FROM address. Returns 0 or 1 depending on the result of the test. In contrast to the stdpoll function, _pollmx does not use cache database and does not fall back to polling the ip if the poll fails. The function can throw one of the following exceptions: e_failure, e_temp_failure.

Built-in Function: number stdpoll   (string email, string domain, string mailfrom)

Performs standard poll for email, using domain as EHLO domain and mailfrom as MAIL FROM address. Returns 0 or 1 depending on the result of the test. Can raise one of the following exceptions: e_failure, e_temp_failure.

In on statement context, it is synonymous to poll without explicit host.

Built-in Function: number strictpoll   (string host, string email,   string domain, string mailfrom)

Performs strict poll for email on host host. See the description of stdpoll for the detailed information.

In on context, it is synonymous to poll host host.

The mailfrom argument can be a comma-separated list of email addresses, which can be useful for servers that are unusually picky about sender addresses. It is advised, however, that this list always contain the ‘<>’ address. For example:

 
_pollhost($client_addr, $f, "domain", "postmaster@my.net,<>")

See also mail-from-address.

Before returning, all described functions set the following built-in variables:

Variable Contains
last_poll_host Host name or IP address of the last polled host.
last_poll_send Last SMTP command, sent to this host. If nothing was sent, it contains literal string ‘nothing’.
last_poll_recv Last SMTP reply received from this host. In case of multi-line replies, only the first line is stored. If nothing was received the variable contains the string ‘nothing’.
cache_used 1 if cached data were used instead of polling, 0 otherwise. This variable is set by stdpoll and strictpoll. If it equals 1, none of the above variables are modified. See cache_used example, for an example.

Table 4.2: Variables set by polling functions