Go to the first, previous, next, last section, table of contents.


String expansion

Most data values are expanded before use. Expansion consists of replacing substrings beginning with $ with other text. The full expansion facilities are described from section 29 below onwards, but the most common case is the substitution of a simple variable. For example, the substring

$reply_address

is replaced by the address to which replies to the message should be sent. If such a variable name is followed by a letter or digit or underscore, it must be enclosed in curly brackets (braces), for example,

${reply_address}

If a `$' character is actually required in an expanded string, it must be escaped with a backslash, and because backslash is also an escape character in quoted input strings, it must be doubled in that case. The following two examples illustrate the two cases:

if $local_part contains \$ then ...
if $local_part contains "\\$" then ...

The variable substitutions most likely to be useful in filter files are:

$home: The user's home directory.

$local_part: The part of the email address that precedes the @ sign -- normally the user's login name. If support for multiple personal mailboxes is enabled (see section 26 below) and a prefix or suffix for the local part was recognized, it is removed from the string in this variable.

$local_part_prefix: If support for multiple personal mailboxes is enabled (see section 26 below), and a local part prefix was recognized, then this variable contains the prefix. Otherwise it contains an empty string.

$local_part_suffix: If support for multiple personal mailboxes is enabled (see section 26 below), and a local part suffix was recognized, then this variable contains the suffix. Otherwise it contains an empty string.

$message_body: The initial portion of the body of the message. By default, up to 500 characters are read into this variable, but the system administrator can configure this to some other value. Newlines in the body are converted into single spaces.

$message_body_end: The final portion of the body of the message, formatted and limited in the same way as $message_body.

$message_body_size: The size of the body of the message, in bytes.

$message_headers: The header lines of the message, concatenated into a single string, with newline characters between them.

$message_id: The message's local identification string, which is unique for each message handled by a single host.

$message_size: The size of the entire message, in bytes.

$original_local_part: When a top-level address is being processed, this contains the same value as the variable $local_part. However, if an address generated by an alias, forward, or filter file is being processed, this variable contains the local part of the original address.

$reply_address: The contents of the `Reply-to:' header, if the message has one; otherwise the contents of the `From:' header. It is the address to which normal replies to the message should be sent.

$return_path: The return path -- that is, the sender field that will be sent as part of the message's envelope, and which is the address to which delivery errors are sent. In many cases, this has the same value as $sender_address, but if, for example, an incoming message to a mailing list has been expanded, then $return_path may contain the address of the list maintainer instead.

$sender_address: The sender address that was received in the envelope of the message. This is not necessarily the same as the contents of the `From:' or `Sender:' header lines. For delivery error messages (`bounce messages') there is no sender address, and this variable is empty.

$tod_full: A full version of the time and date, for example: Wed, 18 Oct 1995 09:51:40 +0100. The timezone is always given as a numerical offset from GMT.

$tod_log: The time and date in the format used for writing Exim's log files, for example: 1995-10-12 15:32:29.


Go to the first, previous, next, last section, table of contents.