O'Reilly logo

Exim: The Mail Transfer Agent by Philip Hazel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

Before-${substr_4_2:$local_part}-After

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required