Chapter 17. String Expansion

The combination of expansions and lookups makes it possible to configure Exim in many different ways. If you want to explore these different possibilities, you need to understand what string expansions can do for you. We cover a number of examples in earlier chapters; this chapter contains a full explanation of the mechanism, and descriptions of all the different expansion items. A reference summary of string expansion, including a list of all the expansion variables, is given in Appendix A.

When Exim is expanding a string, special processing is triggered by the appearance of a dollar sign. The expander copies the string from left to right until it hits a dollar, at which point it reads to the end of the expansion item, does whatever processing is required, and adds the resulting substring to its output before continuing to read the rest of the original string. Most, but not all, expansion items involve the use of curly brackets (braces) as delimiters. For example, when expanding the following string:


the expander copies the initial substring Before-, then processes the expansion item ${substr_4_2:$local_part} to produce the next part of the result, and finally adds the substring -After at the end.

To make it possible to include a dollar character in the output of an expansion, backslash is treated as an escape character by the expander. A number of special sequences, such as \n for newline, are recognized.[158

Get Exim: The Mail Transfer Agent now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.