Before we look at how it's used with sendmail, let's have a brief look at m4 itself. We've just mentioned that it is a macroprocessor, but what exactly does that mean, and what does it do?
Given a text file as input, m4 will scan the file looking for predefined tokens it has been told about. If it finds any, it will perform a transformation on them, which will differ depending on what tasks we would like it to perform. Let's look at an example to show how this works in practice:
hydrogen# m4 define('eg', 'this is the first example') eg this is the first example hydrogen#
First we can see that m4 reads standard input and writes to standard output. After starting the program, we've defined a macro that will substitute the string “eg” for the ...